07-02-2008, 01:06 PM
Just wondering whats the function used in jQuery for ajax XMLHttpRequest
Like the following
0 The request is not initialized
1 The request has been set up
2 The request has been sent
3 The request is in process
4 The request is complete
More info here: http://www.w3schools.com/ajax/ajax_xmlhttprequest.asp
You shouldn't ever need to probe those individual states when using jQuery to make an Ajax connection. The function jQuery.ajax() supports the "error", "success", and "complete" parameters that let you fire your own custom code for any of the relevant Ajax outcomes. Something like:
alert('Error fetching content.<br />Server Response: '+ajaxrequest.responseText)
Native XMLHttpRequest states like 1 or 2 don't ever fire at all in some browsers, so they are not reliable anyway.
07-03-2008, 04:59 AM
Can this be done with $.get method?
If yes, can ya show an example plz?
Well, $.get() is basically just a shorthand, limited version of $.ajax(). I don't believe it gives you access to some of the states you mentioned:
Load a remote page using an HTTP GET request.
This is an easy way to send a simple GET request to a server without having to use the more complex $.ajax function. It allows a single callback function to be specified that will be executed when the request is complete (and only if the response has a successful response code). If you need to have both error and success callbacks, you may want to use $.ajax.
Why not just use the lower level, $.ajax() method?
07-03-2008, 08:51 AM
Can I have 2 Submit buttons in a form one for adding and the other for deleting?
Well, I wanna do the addition and deletion in jQuery.
How do I implement the condition statement in jQuery that if submit button is add then do the add function and if the submit button is delete then do the delete function?
07-07-2008, 01:36 PM
Sounds like you need two different functions that do either of those steps.