[jQuery] Can't Get Data Back from $.ajax() Call in IE7?
I've been testing this past few weeks in IE7, and I've got one
specific case where $.getJSON() seems to call the server
intermittently, and usually not at all. I use $.getJSON() a lot. In
FF and Safari it always works, and even in IE7 it usually seems to
work, but not in this case for some reason. I've tried setting cache
to false:
$.ajaxSetup({
cache: false
});
...but that doesn't seem to have fixed it yet.
So now I'm trying plain $.ajax() instead of $.getJSON:
$.ajax({
url: "/myFunction?type=json",
cache: false,
mode: "sync",
data:
{
theDataToCheck:theDataToCheck,
GramsOrML: GramsOrML,
UnitCount: UnitCount,
UnitsOfMeasurement: UnitsOfMeasurement,
LetOtherPeopleUseThisInfo:LetOtherPeopleUseThisInfo,
ajax_call: 'true'
},
dataType: "jsonp",
success: function(data) {
//handle data
//data comes back undefined in IE7
}
});
This always sends the call to the server, so I'm part of the way there
towards fixing this bug. However, although this $.ajax() call always
works in FireFox and Safari, in IE7, the data seems to come back
undefined. Here's the skeleton of the PHP code:
$JasonCallBack = $_REQUEST['callback'];
//put return data in $theData array
$S = $this->json->encode($theData);
$S = $JasonCallBack . '(' . $S . ');';
echo $S;
What can I do to get the data variable to be decoded properly in my
$.ajax() call in IE7?