Email web hosting - CHAPTER 3 CONTENT CHUNKING PATTERN Document Chunk
CHAPTER 3 CONTENT CHUNKING PATTERN
| Nothing |
In the HTML code, the class Asynchronous is instantiated and the asynchronous.complete property is assigned a function callback. How the Asynchronous class works and which properties need to be assigned was discussed in Chapter 2. The instantiation of asynchronous occurs as the HTML page is loading. After the page has loaded and is complete, the event onload is executed which is the event step of the pattern implementation. The onload event calls the asynchronous.call method to execute an XMLHttpRequest request to download an HTML chunk which is the request step of the pattern implementation. After the request has completed, a response is generated that when received by the client results in the method asynchronous.complete being called. The received response is the response step of the pattern implementation. In the example, the method asynchronous.complete is assigned an anonymous JavaScript function. In the implementation of the anonymous function, the method getElementById is called to insert the XMLHttpRequest results into an HTML element. The HTML element is located by the identifier insertplace, which happens to be the HTML tag td. The referencing of the Dynamic HTML element and its assignment using the innerHTML property is the HTML injection which represents the injection step of the pattern implementation. In the example, it is odd that after the HTML page is downloaded, processed, and considered complete, another piece of logic is called. The other piece of logic is used to retrieve the rest of the content in the form of a chunk. The server-side code could have generated the complete page in the first place. However, it was illustrated in this fashion to show how simple the implementation of the Content Chunking pattern can be. The example illustrated reacting to the onload page event, but any event could be used. For example, examples in Chapter 2 used the button onclick event. A script could even simulate events by using the Click() method. This example illustrated separation of the HTML page s appearance from its logic. The framework HTML page could be realized by an HTML designer. For the area where content is injected, the HTML designer would need only to add a placeholder token identifier such as Nothing. A server-side web application programmer creates the generated content that replaces the placeholder. The HTML designer would not need to be concerned with any server programming technology because the framework HTML page would contain only client-side instructions.
In case you need quality webspace to host and run your web applications, try our personal web hosting services.