2

jQuery -> getJSON -> Data load fails on outside server.

This works fine on all other browsers but IE9. I've set headers (active...origin:* etc) on the php script that delivers JSON data from the primary server.

What needs to happen to jQuery / getJSON to get IE to retrieve the data.

ThinkingStiff
  • 64,767
  • 30
  • 146
  • 239
Mark
  • 21
  • 1
  • 1
    See: http://stackoverflow.com/questions/6318996/jquery-getjson-not-working-properly-in-ie8-with-gdata-json-c-why/6320496#6320496 – Dr.Molle Jun 21 '11 at 02:59
  • Adding callback=? is a no go for me; in fact, that kills all the browsers from sending requestion – Mark Jun 21 '11 at 03:15
  • IE get a ";" error too when adding the callback – Mark Jun 21 '11 at 03:30
  • A couple of things that you might already have checked but aren't mentioned above - is your server definitely returning a response? You might find that it's the server choking on something (headers, missing cookies?) specific to IE's request. Firebug or Fiddler useful here. Second, is there any chance the data you are passing is serializing to be greater than 2000+ characters in the GET url? Sounds unlikely but does happen. What happens if you POST? – tomfumb Jun 21 '11 at 04:13
  • I did some extensive research; I'm utilizing callback=? it seems that IE is recognizing the call (via console, before no net request were shown). Utilizing callback=? prevents jquerys getJSON function(data) right? Cause I never get data back after the callback goes through – Mark Jun 21 '11 at 04:17
  • Is it even possible to utilize the follow up function(data) from jquerys getJSON when utilizing the callback? This is what I'd like to really do. So far, with out the callback, it works in everything but I.E.; i've set the origin headers and etc (*); but IE is being the pain – Mark Jun 21 '11 at 04:20
  • I figured it out; in the incoming json you must set the call back name before the []($json->data); This really needs to be noted more clearer. – Mark Jun 21 '11 at 05:05

1 Answers1

0

try using JSONP

here is what you need to do in your php script

<?
$data = '{"name" : "hello world"}';
echo $_GET['jsoncallback'] . '(' . $data . ');';
?>

and in the url just add

&jsoncallback=?
Kishore
  • 1,914
  • 1
  • 15
  • 22