Javascript variable assignment of object returns string
I am trying to run the following code:
var status = null;
$.ajax({
type: "GET",
url: "/status",
success: function(data, textStatus, jqXHR){
status = data;
},
error: function(jqXHR, textStatus, errorThrown){
console.error(textStatus + ": " + errorThrown);
}
});
The interesting part is the following line: status = data;
In the debugger I can see that data has the value Object {7100665: 0,
8800798: 0}. jQuery correctly parses the JSON-string returned from the
server into an object.
However, one line later the global variable status has the value "[object
Object]" and behaves like a string object - string does not have the
object assigned to it as expected.
It looks like there was an implicite typeof call in the assignment going
on, which cannot be, right? Is there some more going on that I am not
aware of? The Content-Type of the ajax call is application/json.
What am I missing/doing wrong?
No comments:
Post a Comment