移动端的搜索用的是from提交

html部分

<form action="javascript:searchSubmit();">
<input  type="search" id="searchKey" name="searchKey" placeholder="输入关键字" />
</form>

js部分

function searchSubmit() {
if($.trim($('#searchKey').val()) != "") {
var data = {
//data数据
};
$.ajax({
data: JSON.stringify(data),
contentType:'application/json',
type: "POST",
url: "请求地址",
dataType: "json",
success: function(rest) {
console.log(rest)
}
});
};
}

posted @ 2017-08-14 14:41  田天1  阅读(226)  评论(0编辑  收藏  举报