I would like to pass 2 javascript string arrays
“myArray1” and “myArray2” from ajax to a webmethod. What I have is the following which is not working.
var myArray1 = new Array();
var myArray2 = new Array();
// the arrays are filled further in the code.
// call to the webmethod:
$.ajax({
type: "POST",
url: "mypage.aspx/SavePage",
data: ??????,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
alert(msg.d);
},
error: function() {
alert("failed");
}
});
I do not know how to pass these arrays in the data: part of the call.
C# part of my code.
public static string SavePage(List<string> myArray1, List<string> myArray2)
{
}
Try this way:
In your codebehind :