How do I get at the raw JSON response from a jQuery $.getJSON()
request?
I just want to print the raw response in an alert()
dialogue in my browser?
As of jQuery 1.5 the jqXHR object is passed in as the third argument of the callback method. The jqXHR object has a reponseText property that contains the raw JSON string.
function callback(data, status, jqXHR) {
alert(jqXHR.responseText);
// or console.log(jqXHR.responseText);
}
If you're using JSONP, this is fundamentally impossible.
If you're sending a normal request to your domain, replace getJSON
with get
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With