How can I add something to serialized form values using jQuery?
I can not figure out the syntax for this.
He开发者_如何学Cre's my code:
$('select[id^="lookup_"]').change(function() {
var d = $("#lookupform").serializeArray();
// This is the problem line
d.push("field=" + $(this).id);
hash = { type: "POST", url: "/map/details", data: d };
$.ajax(hash);
return false;
});
I know that problem line is totally wrong. I basically want to let the server side know from which the submission came from. Can anyone help?
this should do:
d.push( { field: this.id } );
You're very, very close. This will work:
d.push("field=" + this.id);
Or, to be consistent with the other array elements:
d.push({field: this.id});
精彩评论