I'm having this simple get request:
$.get('ri/i18n/locale')
.done(function() {
console.log(this);
})
.fail(function() {
console.log(this);
})
.always(function(){
console.log(this);
});
Unfortunately none of the handlers are ever called.
I cann confirm that calling ri/i18n/locale
in the browser returns a valid JSON string. I'm using jQuery 1.11.1 .
Any ideas what's wrong?
Your issue might be what version of jQuery you are using. Before jQuery 1.5, a jqXHR
object was not returned with a $.get()
, which is what allows you to use the promise behavior. The relevant jQuery documentation .
After all I just missed the asynchronous nature of the ajax call. I had a breakpoint on all console.log
statements and the statement following the ajax call. Since the the statement after the ajax call was hit first I assumed none of the console.log
statements gets called.
Since I need the result of the ajax call to go on, I have to move all my code into the done()
function.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.