问题
here's my code:
var ids = $.map($("#container-1").children(), function(n, i) {
return n.id;
});
$.ajax({
type: 'POST',
url: 'Loader.asmx/Active',
data: "{'divs':'" + ids + "'}",
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function(msg) {}
});
回答1:
Javascript;
var ids = $.map($("#container-1").children(), function(n, i) {
return n.id;
});
$.ajax({
type: 'POST',
url: 'Loader.asmx/Active',
data: { divs: ids.join("|") },
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function(msg) {}
});
in C#:
string[] arrIds = divs.Split('|');
回答2:
I wouldn't think you'd need to render your data as a string.
Wouldn't this work?
data: { divs: ids },
Assuming that ids is a JavaScript string array, that is.
来源:https://stackoverflow.com/questions/1457637/how-do-you-pass-an-array-string-to-a-web-service-via-jquery