我有一个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中的dev工具进行调试,并认为mayb IE 11不支持stringify?
让我知道!感谢。
答案 0 :(得分:1)
我正在使用此
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); }
});
在任何浏览器中为我工作