我有一个 ajax 代码,它接受 2 个字符串参数,并将这些参数传递给后面的代码 C# 方法,该方法更新数据库中的用户记录。
这是我的代码:
// Grabs the Customer_ID
<%string inputCust = Session[SessionKey.CUSTOMER_ID].ToString();%>
var custNoString = "<%=inputCust%>"
// Final input for the password.
var finalValue = value2.value;
// Create the data object for the 2 parameters for the c# Method
var dataObj = {};
dataObj.custID1 = custNoString;
dataObj.tempPass2 = finalValue;
// { "custID1" : custNoString , "tempPass2" : finalValue };
// AJAX request to run the function
$.ajax({
type: "post",
url: "reciept.aspx/AddGuestAccount",
contentType: "application/json; charset=utf-8",
data: JSON.stringify(dataObj),
dataType: "json",
success: function(){
$("#Screen1").hide();
$("#Screen2").show();
},
error:function(error){ alert("We are sorry, the action failed. Error: " + error);}
});
return true;
现在,当我尝试在 IE 11 中运行代码时,出现“无法获取未定义或空引用的属性“stringify””异常。
有谁知道问题出在哪里吗?我正在使用 Jquery 1.7,我可能需要更新到最新版本吗?我的ajax代码有可能是错误的吗?
我尝试在 IE 中使用开发工具进行调试,并认为 IE 11 可能不支持 stringify?
请告诉我!谢谢。
最佳答案
我正在用这个
var custNoString = "value1"
// Final input for the password.
var finalValue = "value2.value";
// Create the data object for the 2 parameters for the c# Method
var dataObj = {};
dataObj.custID1 = custNoString;
dataObj.tempPass2 = finalValue;
$.ajax({
type: "post",
url: "about.aspx/diffData",
contentType: "application/json; charset=utf-8",
data: JSON.stringify(dataObj),
dataType: "json",
success: function () {
$("#Screen1").hide();
$("#Screen2").show();
},
error: function (error) { alert("We are sorry, the action failed. Error: " + error); }
});
在任何浏览器中为我工作
关于javascript - 无法获取未定义或空引用 IE 11 ASP.NET 的属性 'stringify',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37031680/