Friday, 30 August 2013

JSON.stringify and JSON.parse wont work in IE9

JSON.stringify and JSON.parse wont work in IE9

Hi Guys I hope you can help as this is driving me up the wall !!
I am running local Vb.net web site and calling a javascript function to
try to post JSON data to a php website on a web based server. My browser
is IE9 and im using visual studio 2010
I started off trying to call JSON.stringify or JSON.parse and neither
would work. I added into my .aspx page the line and it still didnt work I
downloaded a json file and referenced it locally from JSON.ORG and it
still doesnt work.
When it gets to the line JSON.stringify - it returns a microsoft
javascript error that JSON is not defined
I have spent two days trying to get this to run and could do with your
help. Any thoughts ??
function jsonSend() {
var JSONJSON = {};
var json =
document.getElementById("ctl00_ContentPlaceHolder1_JsonTfr").value;
JSONJSON['insc_users'] = json;
var jsonStr = JSON.stringify(JSONJSON); //**this is where it fails**
$.ajax({
type: 'POST',
url: 'http://www.thiswebsite.co.uk/receive.php',
dataType: 'json',
data: jsonStr,
success: function (data) {
// handleLoginLocally(u, p);
console.log('LOG.LOGIN: trying login using local storage');
},
error: function () {
console.log('LOG.LOGIN: login remote server failed');
// handleLoginLocally(u, p);
console.log('LOG.LOGIN: trying login using local storage');
}
});

No comments:

Post a Comment