I'm experiencing a rather weird issue where IE (IE11) is having trouble saving a variable returned from a GET, it's one specific variable. The other variables returned in the object are valid data and the one variable that isn't working in IE is working correctly in other browsers.
Below is a sample of my actual code with results.
$.get("myPHPscript.php", function( data ) {
// Parse result
obj = jQuery.parseJSON(data);
jobs = obj.jobs;
// Loop through object
for(var key in jobs)
{
name = jobs[key].name; // Valid data in all 3 browers
console.log("Name: " + name);
id = jobs[key].id; // Valid data in all 3 browers
console.log("ID: " + id);
status = jobs[key].status; // Valid data in Firefox, Chrome but EMPTY in IE.
console.log("Status: " + status);
}
});
Here is a sample of the data returned in the GET call that I have from the browser network inspect capability. This is identical in all 3 browsers.
{
"jobs":[
{
"id":"4142",
"name":"Test",
"status":"closed"
},
{
"id":"4143",
"name":"testtttttt",
"status":"open"
},
{
"id":"4144",
"name":"Test job subclient",
"status":"open"
}
]
}
Here is a picture of the results from the browsers with the above code.
Note: If I save obj to a global variable and try to access status in IE console, it returns valid data.
While I couldn't resolve the issue, changing the variable name from "status" to anything else produces valid data in IE.
According to Microsoft, status isn't a reserved word in Javascript
https://msdn.microsoft.com/en-us/library/ie/0779sbks%28v=vs.94%29.aspx
So I'm not sure what was producing the issue to begin with.
Does not work in IE
status = jobs[key].status; // Valid data in Firefox, Chrome but EMPTY in IE.
console.log("Status: " + status);
Does work in IE
status1 = jobs[key].status; // Valid data all 3 browsers
console.log("Status: " + status1);