I have an ajax form that I need to serialize. I also need to set the _method of the data form manually. Here is my current implementation.
$.ajax({
url: http://someposturl.com/object,
type: 'POST',
data: {
_method: method
},
data: $('form').serialize(),
success: function(json) {
alert("YAY");
},
error: function(json){
alert("BOO!"):
}
});
Unfortunately, as I’m doing it above, the data variable is being overwritten.
How would I write this so that the data contains both the _method and the serialized form?
try this: