{"action":"opened","issue":{"url":"https://api.github.com/repos/kimown/kimown.github.io/issues/22","labels_url":"https://api.github.com/repos/kimown/kimown.github.io/issues/22/labels{/name}","comments_url":"https://api.github.com/repos/kimown/kimown.github.io/issues/22/comments","events_url":"https://api.github.com/repos/kimown/kimown.github.io/issues/22/events","html_url":"https://github.com/kimown/kimown.github.io/issues/22","id":112003475,"number":22,"title":"JD移动版的搜索框","user":{"login":"kimown","id":7932380,"avatar_url":"https://avatars.githubusercontent.com/u/7932380?v=3","gravatar_id":"","url":"https://api.github.com/users/kimown","html_url":"https://github.com/kimown","followers_url":"https://api.github.com/users/kimown/followers","following_url":"https://api.github.com/users/kimown/following{/other_user}","gists_url":"https://api.github.com/users/kimown/gists{/gist_id}","starred_url":"https://api.github.com/users/kimown/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kimown/subscriptions","organizations_url":"https://api.github.com/users/kimown/orgs","repos_url":"https://api.github.com/users/kimown/repos","events_url":"https://api.github.com/users/kimown/events{/privacy}","received_events_url":"https://api.github.com/users/kimown/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-10-18T06:16:10Z","updated_at":"2015-10-18T06:16:10Z","closed_at":null,"body":"http://m.jd.com/\r\n![搜索框](https://img.alicdn.com/imgextra/i2/1128418138/TB2dYQFgXXXXXX2XXXXXXXXXXXX_!!1128418138.png)\r\n这是初始化页面，当我们点击搜索框时，触发click事件，这里是发出统计信息\r\n![](https://img.alicdn.com/imgextra/i1/1128418138/TB2BCgqgXXXXXbZXXXXXXXXXXXX_!!1128418138.png)\r\n这是\r\n```\r\n e.sendMping(g);\r\n```\r\n发出的统计信息\r\n![](https://img.alicdn.com/imgextra/i3/1128418138/TB2zJf9gXXXXXXsXFXXXXXXXXXX_!!1128418138.png)\r\n这里使用了一个500毫秒的定时器，轮询搜索框内用户输入内容，如果是已搜索的内容，走searchLoadFromHistory方法，查询本地localstorage的数据；如果不是已搜索的内容，走searchLoadFromKeyword方法，ajax查询后台。\r\n![](https://img.alicdn.com/imgextra/i4/1128418138/TB2eCMhgXXXXXbiXpXXXXXXXXXX_!!1128418138.png)\r\n这是前端ajax请求代码\r\n![](https://img.alicdn.com/imgextra/i4/1128418138/TB22EgygXXXXXbsXXXXXXXXXXXX_!!1128418138.png)\r\n这是前端ajax请求内容\r\n![](https://img.alicdn.com/imgextra/i3/1128418138/TB2s4MAgXXXXXa.XXXXXXXXXXXX_!!1128418138.png)"}}