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:
$.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
Post a Comment