Jquery 当ajax请求发送时,如何执行一些操作?

Jquery 当ajax请求发送时,如何执行一些操作?,jquery,ajax,jsp,Jquery,Ajax,Jsp,嗨,我是通过ajax发送请求的,我想在ajax请求发送时处理一些事情 我使用了: $('#shwall').ajaxStart(function(){ $('#shwall').html("<img alt=\"loading...\" src=\"img/ajax_loading_new.gif\"/>"); }); 但每次发送ajax请求时,我的页面都包含多个ajax请求: $().ajaxStart(function(){});

嗨,我是通过ajax发送请求的,我想在ajax请求发送时处理一些事情

我使用了:

    $('#shwall').ajaxStart(function(){
        $('#shwall').html("<img alt=\"loading...\" src=\"img/ajax_loading_new.gif\"/>");    
    });
但每次发送ajax请求时,我的页面都包含多个ajax请求:

  $().ajaxStart(function(){});
代码运行,但我不希望这样,我希望为特定的ajax请求运行此代码 那我该怎么做呢

提前谢谢你

使用

beforeSend:function(){

就像你在使用成功一样

参考:

你可以给出如下建议:

$.ajax({
                 type : 'Post',
                 url : 'employee.jsp',
                 data: "emplist="+id,
                 beforeSend : function()
                 success : function(data){
                     $('#employeereport').html(data);                       
                 }
                });
使用

$.ajax({
                 type : 'Post',
                 url : 'employee.jsp',
                 data: "emplist="+id,
                 beforeSend : function()
                 success : function(data){
                     $('#employeereport').html(data);                       
                 }
                });
beforeSend: function(){}

$.ajax({
        type : 'Post',
        url : 'urpage.jsp',
        data: "data="+data,
        beforeSend : function(){
                         //code
        },
        success : function(data){
                     $('#dd').html(data);                       
        }
 });