beneath ajax paradim — onreadystatechange

ajax paradigm can be very confusing. Don’t ask me exactly why. Let’s really master one piece at a time. Let’s try to memorize a component’s relationship with other components. Memorize and try to develop quick reflex that you had with struts, java, unix, perl,
 
#1 reflex:
                    “onreadystatechange callback = javascript function triggered by data from GET/POST”
 
 
You already know that a GET (ignore POST for now) always has a caller function, in our case a js function. Caller function always receives the Gdata (GET-data), dictated by http. Now sit up — Gdata is passed to a “special-js” function. Avoid cliches like “callback”.
 
* special-js uses the data returned by GET
* special-js = a JAVASCRIPT function
* => special-js runs in the browser  
* => special-js usually modifies the DOM content in the browser
* special-js checks if (readyState == 4)
 
special-js function, as a javascript function, is often defined amid the html and has a name. The special-js function name must be set with
       
        XMLHttpRequest  .  onreadystatechange = your_special_javascript_function_name
 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s