3

My sender function:

var parseData = JSON.stringify(requestData);
        iframe[0].contentWindow.postMessage({ request: parseData, request_id: dataOrign.length - 1 }, '*');

and function of receiving a request:

$(window).on("message", function(e) {
        var requestData = JSON.parse(e.originalEvent.data.request);
    }

in IE 9 I have this error:

0x800a03f6 - JavaScript runtime error: Invalid character in:

var requestData = JSON.parse(e.originalEvent.data.request);

In other browsers everything works fine. tell me what the problem is and how to solve it?

Geray Suinov
  • 3,521
  • 3
  • 16
  • 19
  • 2
    Can you post what e.originalEvent.data.request is? Console.log or something. – Tdelang Aug 09 '13 at 08:20
  • console.log( e.originalEvent.data.request) : undefined. I don't know why :( – Geray Suinov Aug 09 '13 at 08:24
  • Probably you need some other attribute of the event e in IE. I don't know which one, so try logging e, and figuring out where the data you expect is. – Tdelang Aug 09 '13 at 08:30
  • For the console.log problem: http://stackoverflow.com/questions/5472938/does-ie9-support-console-log-and-is-it-a-real-function – ep0 Aug 09 '13 at 09:16
  • Did you try parsing the JSON response in sites such as jsonlint.com or www.jsoneditoronline.org to see if they can find a parsing error ? – Veverke Jul 24 '14 at 14:12

1 Answers1

0

Are you using IIS? If so, open IIS and look at your MIME types. Check to see if you have one called .json. If not, simply add one called .json and set it to application/json.

Hope it helps :)

  • 1
    Answers should be reserved for something that is a fix to the problem. When you have questions about their situation, it is better to leave a question in the comments so they can provide enough information for you to provide an answer. – Steve Mitcham Jan 14 '15 at 22:31
  • Thank you. This is my first answer ever, I was not really sure about how to respond. Will keep it in mind for future responses :) – icapetillos Jan 14 '15 at 23:05