I am trying to implement the same code that was mentioned in this question
Currently I have the following code:
var pagePath = window.location.pathname;
var paramList = '';
if (paramArray.length > 0) {
for (var i = 0; i < paramArray.length; i ++) {
if (paramList.length > 0) paramList += ',';
paramList += "{'id':'" + paramArray[i].id + "',
'collapsed':'" + paramArray[i].collapsed + "',
'order':'" + paramArray[i].order + "',
'column':'" + paramArray[i].column + "'}";
}
}
paramList = '[' + paramList + ']';
$.ajaxSetup({ cache: false });
//Call the page method
$.ajax({
type: "POST",
url: pagePath + "/" + fn,
contentType: "application/json; charset=utf-8",
data: "{'items': **'**" + $.toJSON(paramList) + "**'**}",
dataType: “json”,
success: successFn,
error: errorFn
});
I am trying to pass this data to the WebMethod
[WebMethod]
public static String SaveData(Dictionary<String, Object>[] items)
The problem is that I keep receiving the error “500 Internal Server Error”.
I’m pretty sure that the data type is causing the problem but just can’t figure it out.
Any ideas?
Is your service decorated with [ScriptService] attribute?
and what’s up with the asterisks? is this some new macro i didn’t get the memo on?
try
“{‘items’: ” + $.toJSON(paramList) + “}”As i see it, you are already creating json. no need for the toJSON
try replacing the single quotes with double quotes. e.g.
your post data should look like this
inline