这是我第一次尝试使用 Ajax 向服务器发送数据。我从这里遵循了很多答案,但我不会停止收到错误:"Message":"Invalid web service call, missing value for parameter: \u0027Products\u0027."
var products = [ { ProductId : 1, ProductName : "Mercedes", Category : "Cars", Price : 25000 }, { ProductId : 2, ProductName : "Otobi", Category : "Furniture", Price : 20000 } ];
function GetProductId() {
$.ajax({
type: "POST",
url: "Default.aspx/GenerateQrCode",
data: { "Products" : products.toString() },
contentType: "application/json; charset=utf-8",
dataType: "json",
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(xhr.responseText);
alert(thrownError);
},
success: function (msg) {
alert('Success');
}
});
}
[WebMethod]
public static void GenerateQrCode(object Products)
{
//Cannot get to here
}