500 Internal Server Error
当我运行向页面方法发出简单 Ajax 请求的应用程序时,我只在 IE 10 中得到这个。我已经在 Chrome 和 Firefox 中对其进行了测试,它在这些中运行良好。请尽快提出相关建议。我将粘贴下面的代码:
function GetProductId() {
$.ajax({
type: "POST",
url: "Default.aspx/GenerateQrCode",
data: "{'Products':" + JSON.stringify([{ ProductId: 1 }, { ProductId: 2 }]) + "}",
contentType: "application/json; charset=utf-8",
dataType: "json",
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(xhr.responseText);
alert(thrownError);
},
success: function (msg) {
var data = $.parseJSON(msg.d);
}
});
}
[WebMethod]
public static string GenerateQrCode(List<Product> Products)
{
List<string> images = new List<string>();
foreach(var product in Products)
{
string qrCodeLocation = (from pic in products
where pic.ProductId == product.ProductId
select pic.QrCode).FirstOrDefault().ToString();
images.Add(qrCodeLocation);
}
JavaScriptSerializer js = new JavaScriptSerializer();
return js.Serialize(images);
}