javascript - callback function not executed in jquery -


i learning send request in jquery. following block of code makes request. checked in servlet request made callback function not invoked. can't figure out problem.

$.get('http://localhost:8080/pc_controlo/statusservlet?id=1001', function(data){ alert('hello'); }); 

and browsers network tab shows this

[01:21:26.759] http://localhost:8080/pc_controlo/statusservlet?id=1001 [http/1.1 200 ok 1ms] 

+

this have done in servlet.

printwriter out = response.getwriter();             out.write("working");             out.close(); 

and .fail(msg){ alert('failed message:'+json.stringify(msg)); gave following message

failed message: {"readystate":0,"responsetext":"","status":0,"statustext":"error"} 

thanks in advance :).

i did few tests replacing url google.com, , encountered same problem. noticed if use .done(), .always(), , .error(), might have better luck figuring out going on. check out jsfiddle:

http://jsfiddle.net/gqfsd/

$.get('http://www.google.com/') .done(function(data) {     alert('success! data loaded: ' + data);    }) .fail(function(msg) {     alert('failed message: ' + json.stringify(msg)); }) .always(function() {     alert('always alerts'); }); 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -