I’m doing a simple post of a form using jquery. The problem is the $.ajax with POST is working but $.post is not. Look at the code below:
$.post(
{
url: url,
data: form.serialize(),
success: function (result) {
alert('startline posted');
}
});
And the working edition
$.ajax(
{
url: url,
type: "POST",
data: form.serialize(),
success: function (result) {
alert('startline posted');
},
error: function (jqXhr, textStatus, errorThrown) {
alert("Error '" + jqXhr.status + "' (textStatus: '" + textStatus + "', errorThrown: '" + errorThrown + "')");
}
});
Been debugging the $.post example until I just wanted to try out the $.ajax edition to get an error msg. But unfortunatly it just worked 🙂
How are the two methods different?
The parameter format for jQuery.post is
url, data, callback, datatype. The parameter for jQuery.ajax isurl, optionsor justoptionsas you are using. In other words, the formatting on your$.postcall is incorrect.