SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Guru phantom007's Avatar
    Join Date
    May 2008
    Posts
    736
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up jQuery ready states

    Hi,

    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



    Thanx

  2. #2

  3. #3
    SitePoint Guru phantom007's Avatar
    Join Date
    May 2008
    Posts
    736
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    But it only shows the complete and initialize stages, what about the others?

  4. #4
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    If you use $.ajax, $.get or $.post the actual XHR object is returned. Then you can query its ready state as you would normally with readyState, without any jQuery abstraction.

    I don't have a lot of experience with jQuery (especially not with the ajax stuff) but this is one of the great things about it. The readyState property is simple enough as it is, so there's no need for jQuery to reinvent the wheel there.

  5. #5
    SitePoint Guru phantom007's Avatar
    Join Date
    May 2008
    Posts
    736
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    can u plz show a small example on readystate with $.get?

    Thanx

  6. #6
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Actually that's not possible with $.get, which is the simple implementation and only calls a callback function when the request has finished. You want $.ajax, which you can use the Ajax events with. They may cover your requirements.

    I suggest you contact the mailing list for this question as I am not sure I have provided an adequate response simply because I am not familiar with jQuery's Ajax stuff. Make sure you use decent English (don't use "plz", "u" or "Thanx") and make your question as clear and concise as possible.

  7. #7
    SitePoint Guru phantom007's Avatar
    Join Date
    May 2008
    Posts
    736
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Question:

    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?


    Thanx

  8. #8
    SitePoint Enthusiast
    Join Date
    Jun 2008
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by cancer10 View Post
    Question:

    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?


    Thanx
    I assume like this
    Code:
    <input type='button' name='delbtn' id='delbtn' value='delete'/>
    <input type='button' name='addbtn' id='addbtn' value='add'/>
    the js
    Code:
    $(document).ready(function(){
      $('#delbtn').bind('click', function(){deleteFunction();});
      $('#addbtn').bind('click', function(){addFunction();});
    });
    done ?

  9. #9
    SitePoint Guru phantom007's Avatar
    Join Date
    May 2008
    Posts
    736
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Can i have the form and button in the processing page and this jquery script on the main page?

    For some reason it does nt work, any idea why?

  10. #10
    SitePoint Enthusiast
    Join Date
    Jun 2008
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by cancer10 View Post
    Can i have the form and button in the processing page and this jquery script on the main page?

    For some reason it does nt work, any idea why?
    I don't understand your statement, please give me examples.

    if you means to separate the file, like the form was embedded on master template, then it is possible.

    $(document).ready(); will be accessed when the page finished loading (browser get all html page and the scripts inside will be executed).

    if for some reason it doesn't work, please check it with your firebug. it might be you have an error inside the javascript code so it prevent another scripts to run.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •