I’m trying to use some jQuery code for Ajax which works well in Firefox or IE version 8+ but I need to work in IE 6 as well, I have this code for toggle and use Ajax
$(document).ready(function () {
$("#S1").click(function
() {
$("#t1").toggle("fast");
$("#P1").toggle("fast");
$("#S1").css("background-color", "White");
var ID = $("#HiddenField1").attr("Value");
var params = new Object();
params.Key = ID;
var myJSONText = JSON.stringify(params);
$.ajax({
type: "POST",
url: "viewMessages.aspx/readen",
data: myJSONText,
contentType: "application/json",
dataType: "json",
});
});
});
when I try to run this one in IE6 it won’t work and in debugger I get
Line 29:
Error : Expected Identifier, String or Number,
(line 29 would be end of Ajax function in my code)
I removed some code to see where the problem is, so I chnaged to this :
$(document).ready(function () {
$("#S1").click(function
() {
$("#t1").toggle("fast");
$("#P1").toggle("fast");
$("#S1").css("background-color", "White");
var ID = $("#HiddenField1").attr("Value");
var params = new Object();
params.Key = ID;
var myJSONText = JSON.stringify(params);
});
});
this one toggles now but I get the error
Line21.
Error: JSON is unidentified,
where do you think the problem is? how can I run some code like this in IE6?
I’m developing in ASP.NET
Remove the extra comma after the data type.
Also you don’t need to stringify the data component nor do you need to declare an new Object.
it can just be
data:{'KEY':ID},To get id just use: