简体   繁体   中英

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 <script type="text/javascript" src="http://www.json.org/json2.js"></script> 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');
    }
    });

You can try adding <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 5.01 Transitional//EN"> or <!DOCTYPE html>

Also check this .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM