i want to load JUST one part of my document,i had to use LOAD function bcause of this,so i tried this function.but i have a problem,i want to set method of this function to POST.i read in jquery manual that this function is using GET method by default,but if your data is an object it will use POST method.i dont know how to do that?i mean using an object in data list!
here is my code :
$("#form_next").live("click", function(event){
var str = $("#form").serialize();
$("#form").load("form.php?ajax=y§ion=request&cid="+$("#country_id").val(), str, function(response, status, xhr) {
alert(response);
});
return false;
});
how can i do that?
You can make a simple tweak here, use .serializeArray() instead of .serialize(), like this:
$("#form_next").live("click", function(event){
var obj = $("#form").serializeArray();
$("#form").load("form.php?ajax=y§ion=request&cid="+$("#country_id").val(), obj, function(response, status, xhr) {
alert(response);
});
return false;
});
This triggers the same logic as passing the data as an object (since you are, specifically an array), and will cause a POST instead of a GET like you want.
Well, you actually already answered your question.
$("#form").load("form.php", {
ajax: y,
section: request,
cid: $("#country_id").val(),
magicstr: str
}, function(response, status, xhr) {
alert(response);
});
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