I am using the jQuery Ajaxy plugin: http://balupton.com/projects/jquery-ajaxy
Is there a way to add POST parameters to each Ajaxy request?
You can use $.ajaxSetup()
to set default options - including (GET/POST) data.
$.ajaxSetup({
data: { foo: 'bar' }
});
These data will be merged with your data specified in the $.ajax()
call.
$.ajax({
type: 'POST',
url: '/test',
data: { abc: 123 },
success: function(resp) { }
});
This will send both foo
and abc
.
You can also move other options like type: 'POST'
into your defaults so you don't have to specify it everytime.
According http://visualjquery.com you can also go this way:
$.ajax({
type: "POST",
url: "some.php",
data: "name=John&location=Boston",
success: function(msg){
alert( "Data Saved: " + msg );
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With