jquery: different response type
I have a AJAX post method that gets xml data from server.
But when user session is over server will response with login page.
And in that case I can't dete开发者_如何学运维ct if response in not xml because $.post
don't call callback function.
How can I detect if response is not xml ?
Thanks!
instead of using $.post
, use $.ajax
and set type: 'POST'
.
You can then do callbacks on all sorts of events, see http://api.jquery.com/jQuery.ajax/ for all details. Your calls will most likely be easy to convert.
$.post
has less features than $.ajax
, but internally it uses $.ajax
to do the real work.
Try to skip specifying dataType in $.post(), then you should get any kind of data and validate yourself if its XML or something else...
精彩评论