gpt4 book ai didi

jquery - ajax请求发送时如何执行一些操作?

转载 作者:行者123 更新时间:2023-12-01 03:52:19 25 4
gpt4 key购买 nike

您好,我正在通过 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请求运行此代码那么我该怎么做

提前致谢...

最佳答案

使用

beforeSend: function(){

就像你正在使用成功一样。

引用:http://docs.jquery.com/Ajax_Events

你可以给:

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

关于jquery - ajax请求发送时如何执行一些操作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7170859/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com