Problem with JSON in Internet Explorer 7
IE8/Chrome,FF work well but Internet Explorer 7 is giving me headaches.
I am trying to get numeric result for actual form
$(".checklist label").click(function () {
checkResults();
});
function checkResults() {
var str = $("form").serializeArray();
$.ajax({
type: "POST",
url: "/data.asmx/GetTotal",
cache: false,
contentType: "application/json; charset=utf-8",
data: JSON.stringify({ data: str }),
dataType开发者_StackOverflow社区: "json",
success: handleHtml,
error: ajaxFailed
});
}
function handleHtml(msg) {
$("#result").text(msg.d);
}
function ajaxFailed(xmlRequest) {
}
What have I done wrong that IE7 wont work?
Thanks
JSON.stringify is not part of IE7.
You'll have to use Douglas Crockford's JavaScript implementation of this:
https://github.com/douglascrockford/JSON-js
More specifically this script:
https://github.com/douglascrockford/JSON-js/blob/master/json2.js
It will add the stringify and parse methods to browser that do not natively implement this (like IE7 and below)
精彩评论