2016-05-04 5 views
0

Ich habe einen Ajax-Code, der 2 String-Parameter übernimmt und übergibt diese Parameter an eine Hinter-Code C# -Methode, die den Benutzerdatensatz in der Datenbank aktualisiert.Kann Eigenschaft 'stringify' von undefined oder null Verweis nicht erhalten IE 11 ASP.NET

Hier ist mein Code:

    // 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; 

Jetzt, wenn ich versuche und den Code im Internet Explorer 11 laufen, ich „Kann nicht bekommen Eigenschaft‚stringify‘undefiniert oder NULL-Verweis“ Exception.

weiß jemand, was das Problem sein könnte? Ich benutze Jquery 1.7 möglicherweise muss ich auf die neueste Version aktualisieren? Ist es möglich, dass mein Ajax-Code falsch ist?

Ich habe versucht, Debuggen mit Dev-Tools in IE und dachte Mayb IE 11 nicht unterstützt stringify?

Lassen Sie mich wissen! Vielen Dank.

+0

https://github.com/douglascrockford/JSON-js –

+0

http://stackoverflow.com/questions/5093582/ json-is-undefined-error-in-ie-only – nurdyguy

+0

Danke Jungs, das Problem liegt in IE 11 für mich, aber nicht IE 8. Glauben Sie, ich sollte JSON3 importieren? – Learn12

Antwort

1

Ich bin mit diesem

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); } 
    }); 

für mich gearbeitet in jedem Browser