jQuery的ajaxComplete:有没有办法知道哪些Javascript函数执行Ajax调用? [英] jQuery ajaxComplete: Is there a way to tell which Javascript function executed the ajax call?

查看:113
本文介绍了jQuery的ajaxComplete:有没有办法知道哪些Javascript函数执行Ajax调用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有.ajaxComplete事件接线像这几个元素:

I have the .ajaxComplete event wired up to a few elements like this:

$(#ElementId)ajaxComplete(功能(A,B,C){});

问题是,我有多个 $。阿贾克斯在我的剧本是由各种功能被称为呼叫。我不希望.ajaxComplete事件触发的每一个控制每一个Ajax调用。从概念上讲,我期待这样的事情:

The issue is that I have multiple $.ajax calls in my script that are called by various functions. I don't want the .ajaxComplete event to fire for every control for every ajax call. Conceptually, I am looking for something like this:

如果(a.function == SearchCustomers){做到这一点}

有没有什么办法可以达到我想要的吗?

Is there any way to achieve what I want here?

编辑:我知道我可以检查我打电话了服务的URL,但我不希望在我的脚本不止一次硬codeA的URL字符串

I realize that I can check for the URL of the service I am calling, but I don't want to hardcode a URL string in my scripts more than once.

推荐答案

您需要做的是这样的:

$.ajax({
    url: "servicecall.html",
    success: function(html){
        //if success
    };
});

这篇关于jQuery的ajaxComplete:有没有办法知道哪些Javascript函数执行Ajax调用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆