Я хотел бы передать 2 строки строки javascript «myArray1» и «myArray2» из ajax в веб-метод. У меня есть следующее, которое не работает.передать несколько массивов; ajax to webmethod
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");
}
});
Я не знаю, как передать эти массивы в data:
части вызова.
C# часть моего кода.
public static string SavePage(List<string> myArray1, List<string> myArray2)
{
}
Посмотрите на это http://www.aspsnippets.com/Articles /Send-and-Receive-JSON-bjects-to-Web-Service-Methods-using-jQuery-AJAX-in-ASPNet.aspx – coder