Reputation: 6388
Is it possible to add some additional parameters to get/post methods in jQuery .
Ex :
$.get(url,{a:b,c:d},function(data){
//codes..
});
Here you can see that it contains two parameters, a and c.
Now think i need to add an additional parameter [e:f]
to every get/post methods in a web page.
is this possible ?
So when we trigger a get/post method it need automatically add a additional parameter .
Thank you .
Upvotes: 2
Views: 552
Reputation: 75317
You can use jQuery.ajaxSetup()
to set defaults.
jQuery.ajaxSetup({
data: {
e: f // obviously `f` needs to be defined in this scope
}
});
However, you should be aware that these parameters will not be included if you use .load()
, due to what is most likely a bug in jQuery.
Upvotes: 3