I am encountering a small issue. Whenever I execute
myVar = $.post('/check_2/', JSON.stringify({"newname": window.NEWNAME,}), callback, 'json')
The variable 'myVar' holds an object. When I use console.log myVar
, the output is something like:
Object {readyState: 1, setRequestHeader: function, getAllResponseHeaders: function,getResponseHeader: function, overrideMimeType: function…}
abort: function (a){a=a||"abort",p&&p.abort(a),w(0,a);return this}
always: function (){i.done.apply(i,arguments).fail.apply(i,arguments);return this}
complete: function (){if(c){var a=c.length;m(arguments),i?k=c.length:e&&e!==!0&&(j=a,n(e[0],e[1]))}return this}
[...]
When I try console.log myVar.success
(for instance), it displays the respective success information. However, when I attempt to access myVar.responseText
(which should contain the call result), it constantly returns undefined
, making it difficult for me to retrieve the desired data.
Any suggestions on how I can access that crucial data?
I realize that I may have misunderstood something regarding post calls, but due to my confusion, I am unsure of the mistake I am making.
I opted for using post instead of get because I need to transmit data to the backend in order to perform database checks.
EDIT: The point where I place console.log:
check2: (callback) ->
console.log "Starting..."
myVar = $.post('/check_2/', JSON.stringify({"newname": window.NEWNAME,}), callback, 'json')
console.log myVar
console.log "success example"
console.log myVar.success
console.log "responseText"
console.log myVar.responseText
EDIT 2
Here is an image of the object displayed by console.log myVar