用ajax beforeSend修改数据 [英] using ajax beforeSend to modify data
本文介绍了用ajax beforeSend修改数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
比方说,我有jQuery的Ajax调用是这样的:
Let's say I have an Ajax call from jQuery like this:
$.ajax({
url: myUrl,
data: myData,
type:'post'
});
我希望能够用添加到myData的
I would like to be able to add to the myData using
$.ajaxSetup({
beforeSend: function(call){...}
});
结果应该是所有Ajax调用(POST和GET)被修改,所以,如果我得到一个额外的参数IsAjax =真
The result should be that all ajax calls (both post and get) is modified so if i get an extra parameter IsAjax=true
推荐答案
<一个href="http://www.bennadel.com/blog/2131-Using-jQuery-ajaxSetup-To-Accumulate-Global-Data-Parameters-For-AJAX-Requests.htm">This博客文章解释了如何使用 $。ajaxSetup
添加数据。它积累了像 $。延长
只要做到这一点:
This blog post explains how you can use $.ajaxSetup
to add data. It accumulates like $.extend
Just do this:
$.ajaxSetup({
data:{
isAjax:true
}
});
这篇关于用ajax beforeSend修改数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文