Just a fast question.
I'm using ajax POST and GET to send json data to a server and retrieve that data back. However, what I'm confused about is getting json info from the GET call.
getMessage = function(){
$.ajax({
url:'/get_messages',
dataType: 'json',
type: 'GET',
success: function(msg){
console.log("got eeeem " + msg );
}
});
};
What i've seen so far implies what i'm getting from the server should be displayed in msg. However in the console log, msg is displayed as "got eeeem [object Object]". So I'm confused as to how to pull the necessary information out of the msg.
My post looks like this:
var packet = {
'username': 'Name',
'message': innerText,
'date': new Date().toUTCString()
};
$.ajax({
url:'/receive_message',
data: JSON.stringify(packet),
type: 'POST',
success: function(msg){
console.log("EUREKA " + msg);
}
});
Specifically from the GET call, I want to retrieve the innerText variable from the json. Any help is much appreciated