您的位置:首页 > Web前端 > JQuery

JQuery中如何使用事件来出发Ajax

2015-10-28 10:52 465 查看
$(document).ready(function(){

$("input[name='customer_name']").keydown(function(e){
if(e.keyCode==13){

search();
}
});
$("input[name='customer_role']").keydown(function(e){
if(e.keyCode==13){

search();
}
});
});

function search(){
var url ='<%=searchCustomerURL %>';
var customerName = $("input[name='customer_name']").val();
var customerRole = $("input[name='customer_role']").val();
$.get(url, {customer_name:customerName,customer_role:customerRole}, function(response) {
if (response.length > 0) {
//$('#<portlet:namespace/>reportTips').html(treeNode.name);
$('#<portlet:namespace/>reportListBox').empty().html(response);
}
});

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: