I would like to know how to submit POST data for a form using the jQuery LOAD function, sending the form’s serialized data.
so, by way of example, how do i do this:
$('someElement').click(function(){
var formData = $('formHere').serialize();
$('anotherElement').load('somePage', formData);
)};
as it stands, this doesn’t work – if won’t POST the data, but rather sends a GET request. I don’t want to start using the $.post method (because i just don’t want to!), am i doing something wrong here?
SOLUTION: use serialiazeArray instead – as in
var formData = $('formHere').serializeArray()
According to the jQuery docs for
.load()it seems as if the POST method is used if the data (in this caseformDatais an object. Otherwise it uses GET. However, the docs for.serialize()indicate that it returns a string. Hence always the GET.