CHAPTER 2 THE NUTS AND BOLTS OF (Free web hosting services)
CHAPTER 2 THE NUTS AND BOLTS OF AJAX First, the this variable is assigned to the instance variable The assignment is important because it is a variable that is managed by JavaScript. Second, the property onreadystatechange is assigned a dynamic anonymous function. An anonymous function is a function without an identifier, which contains only a signature and implementation. Using an anonymous function in the context of a function allows the referencing of variables in the anonymous function that were defined in the function itself. This means the variable instance is available for referencing in the anonymous function. What makes this feature a big deal is that when the anonymous function is called, the caller of Asynchronous_call will already have exited the function and be doing something else. The reason the local variable instanceis still available is because JavaScript sees a reference and does not garbage-collect it until the this_xmlhttp instance is garbage- collected. Putting all of this together in the HTML code, the Asynchronous property complete is assigned the functions AsyncUpdateEvent and AsyncUpdateEvent2. Whenever any of these functions are called, the this references a valid instance of Asynchronous. Then the code that was referencing myState, which should have worked, would work. Looking at the HTML code, you can see that the AsyncUpdateEventthis references the variable asynchronous, and AsyncUpdateEvent2this references the variable asynchronous2. Figure 2-8 shows the proof that the thisvariable is assigned. Figure 2-8. Debugger illustrating that a function does reference a class instance
Note: If you are looking for high quality webhost to host and run your jsp application check Vision jsp web hosting services