uses of success and complete events in Jquery Ajax

. Wednesday, December 14, 2011
0 comments

Hello Friends,after a long time I'm writing this post.well everyone of us uses Ajax and there are two Events in this

Success : this event is called when your request get succeed. else this does not call.

Complete: doesn't matter whether your request get succeed or not, this event always called,and you can   check various http status code like 200 for OK,501 for Internal Server Error, 400 bad ,404
page not found etc.inside this event for the response for xmlhttprequest.


Which event fires first.?

between success and complete event success event fires before complete event. for details about the sequence of these event check on the official site of jquery ajax here

here is a simple code snippet







the ajax is called when GetQoute form is submitted and receives the httpxmlresponse which later displayed inside the various div's in success event. and if status code received is 200 then success alert message shown in complete event.

What the trick inside this ?

well, as success is fired before complete event we can get response data only in success event and not in complete event because this is useful only for check response status. in the above code,data corresponding to openingPrice,Ratings are displayed but not displayed for closingPrice because its inside complete event.

Hope you enjoyed this.Thanks

Really a Great book by Mr steve sanderson for Asp.net MVC

. Tuesday, December 13, 2011
0 comments

Download this Ebook from Here.
also follow steve sanderson for asp.net mvc updates here