将一般参数添加到使用jQuery进行的所有ajax调用中 [英] Adding a general parameter to all ajax calls made with jQuery

查看:78
本文介绍了将一般参数添加到使用jQuery进行的所有ajax调用中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用AJAX根据需要从服务器加载数据。我目前正在努力将服务器软件更新到最新版本。我注意到的一件事情发生了变化,现在每个请求都需要我传递一个令牌。这意味着我必须为每个请求添加一个新参数。我希望通过一般方法实现这一点,而不必修改每一个AJAX调用。

I'm using AJAX to load data from the server as needed. I'm currently working on updating the server software to the latest version. One of the things I noticed that has changed is that every request now requires me to pass along a token. This means I have to add a new parameter to every request. I'm hoping to achieve this by a general method, without having to modify every single AJAX call.

任何指针?

推荐答案

你可以使用 $。ajaxSetup 方法如以下文章。

这篇关于将一般参数添加到使用jQuery进行的所有ajax调用中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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