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

$(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);
            }
        });
        
        
    }

posted on 2015-10-28 10:52  airycode  阅读(443)  评论(0编辑  收藏  举报

导航