ajax-chosen with ASP.NET MVC
cmjacques opened this issue · 1 comments
cmjacques commented
I'm trying to use ajax-chosen with in ASP.NET MVC3.
Normally I 'stringify' my data (using JSON.stringify from json2.js) before posting it so that ASP.NET can understand it.
I can't see any way of controlling how the data is posted to the server. Is there a way to stringify the data?
Thanks,
Chris
cmjacques commented
I worked it out - you can use dataCallback to massage the data before the ajax request happens.
For example:
dataCallback: function (data) {
return typeof data != 'string'
? JSON.stringify(data)
: data;
}
To avoid stringifying the data multiple times, I first check if it has already been stringified by checking its' type. Stinfigied data is of type string.
Great plugin - keep up the good work!