Google


ADBRITE ads links
You are here: CodeIdol.com > Ajax > Head Rush Ajax > Making Ajax Requests Speaking The Language > Checking The Ready State

SAVE
Digg
Shown on del.icio.us del.icio.us
See Whos Talking About This on Technorati Technorati
I've Reddit reddit

2.30. Checking the ready state

Now that you've got getCustomerInfo() working, and the browser knows to call updatePage() when the request's ready state changes, it's time to write the callback function for the Break Neck app. Let's start out by checking that ready state, and making sure the request has been completed before doing anything to the HTML.

Add a new function to your pizza.html file, called updatePage(), and start with this code:

    function updatePage() {You HAVE to make sure the name of this function matches up
to the function name you assigned to onreadystatechange in getCustomerInfo().
      if (request.readyState == 4) {This if statement makes sure that none of the rest
of the code runs unless the ready state is "4", which means the server's finished, and
it's safe to use the response data.
        /* Get the response from the server */Remember, you declared the request
variable in your static JavaScript, so any function can use it.
        /* Update the order form */You'll write code to take care of both of these
things over the next few pages.
      }
    }


SAVE
Digg
Shown on del.icio.us del.icio.us
See Whos Talking About This on Technorati Technorati
I've Reddit reddit

You are here: CodeIdol.com > Ajax > Head Rush Ajax > Making Ajax Requests Speaking The Language > Checking The Ready State
   
Related tags







Popular Categories
Unix books and guides
AJAX popular information
C# language guides
Windows books and cookbooks
.......






© CodeIdol Labs, 2007