2011-08-24 76 views
2

嗨我送通过Ajax请求,我想处理的东西时,Ajax请求发送如何在ajax请求发送时执行一些操作?

我用:

$('#shwall').ajaxStart(function(){ 
     $('#shwall').html("<img alt=\"loading...\" src=\"img/ajax_loading_new.gif\"/>");  
    }); 

和我的Ajax请求的代码就像下面:

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

但当我每次发送ajax请求时,我的页面包含多个ajax请求:

$().ajaxStart(function(){}); 

代码运行,但我不想这样我想运行特定的Ajax请求 让我怎么做到这一点的代码,

在先进的感谢...

回答

2

使用

beforeSend:功能(){

像你使用成功。

参考:http://docs.jquery.com/Ajax_Events

你可以给这样的:

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

由于其工作......这就是我想要的..... – swan

1

使用

beforeSend: function(){} 

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