Wondering if anyone has used jQgrid to post dynamic data from another form on the same page. Dynamic in that I don\'t know the input names to post, but would rather just po
I am not sure in which form you want to get the data from the form on the server side. Nevertheless I would suggest you to use postData
in the following form
postData: {
filter: function () {
var result = {}, i, item,
formInfo = $('form#myForm').serializeArray(),
l = formInfo.length;
for (i = 0; i < l; i++) {
item = formInfo[i];
result[item.name] = item.value;
}
return JSON.stringify(result);
}
}
In case of the following test form
The result
variable will be
var result = {
a: "1 from a",
b: "2 from b",
c: "3 from c",
d: "4",
e: "5"
}
So no conversion of the data will be done. Then I suggest to convert object result
to JSON string using JSON.stringify
. (Depend on the server code it could be not needed.) So the filters
parameter will be sent as
{"a":"1 from a","b":"2 from b","c":"3 from c","d":"4","e":"5"}
You can use Fiddler or Firebug to examine the HTTP traffic of the corresponding small demo.