Ajax 1 Ajax or Ajah
* Many of the classic applications of Ajax are the use of XMLHTTP space access daemon, background program return script with Eval callback or return simple data way to develop. The advantage of such a development pattern is that the design is simple and lightweight, with developers who are familiar with DHTML to be able to compare chunks, cross-browser problems are easy to solve, and simple applications are enough. Gmail,google suggest are all in this way. But it seems to me that Gmail has Ajah applied to the limit, and more complex data structures are starting to get a bit out of the way to organize them with simple numbers and callbacks.
* A traditional approach to Ajax is to dynamically generate part of a page after returning a complete XML file and using a script (control) to parse the XML and then manipulate the page's DOM nodes. The advantage of this is that you can take advantage of the powerful expressive power of XML to transmit a variety of data structures, with the disadvantage that the DOM is not efficient, and IE has a lot of bugs on the API for DOM operations. It's called "Pre-Ajax," because we've been doing this for many years before the term Ajax came into being.
* Ajax Another traditional approach is to return the full XML file behind the background and then use the script (the control) to parse the XML to generate the HTML code to be poured back into the layer of the page. This avoids some of the problems with the page Dom operation, and the use of some of the optimization techniques of string computing (primarily arrays and regular applications) to generate pages is quite efficient when generating more content. In my opinion, this is the future trend of development.
My current project mainly uses the third way, combining the second. I used a small frame of my own to simulate the syntax of JSP to generate HTML code, but relied on the browser's XML parsing API, so it was difficult to cross the browser. Google's Open source project AJAXSLT provides a pure JS XSLT solution, which is more powerful, and can be used to generate HTML or other forms of data in the local application of XSLT parsing XML, but brings the technical threshold of XSLT. The ZK on SF seems to be good too, but it brings the technical hurdle of XUL, which is tied to the Java server.
2 CACHE
If you use the XMLHTTP control, IE will host the cache policy when you initiate the HTTP request, often updating the data but not getting the updated data. Initially, an attempt was made to force an update by adding random numbers behind the URL in the traditional way, but IE still did not issue a new request.
One solution is to write expires:0 or other headers in the background that prohibit the front desk cache, but this will result in unnecessary server pressure, response latency, and bandwidth wastage when the data is not updated.
A slightly better solution is when the foreground is forced to update data after submitting the data:
Xmlhttp.setrequestheader ("If-modified-since", "0");
3 system error:-1072896748.
When you use XMLHTTP to receive data, you often use XMLDOM.loadXML ( Xmlhttp.responseXML.xml) to determine the correctness of the returned data, but sometimes it triggers a 1072896748 system error if the incorrect XML is sent back in the background. This is because Xmlhttp.responsexml has not parsed the object, and we are also trying to access its XML attributes to trigger.
The solution is to do the try/catch when using Responsexml.xml or responsetext:
Try{var tmp = Xmlhttp.responsexml.xml}catch (ex) {err=true;}
Some people like to catch the time to Judge exception.description== "system error:-1072896748." "If the client is not a simplified Chinese version of the system, it will not be judged." In fact, this place as long as there are anomalies, must go to the exception handling process, do not distinguish so carefully.
Original address: http://www.blogjava.net/emu/archive/2005/11/22/20888.html
- Ajax: A new way to build Web apps
- Discussion on the error handling mechanism of AJAX (2)
- Discussion on the error handling mechanism of AJAX (1)
- First experience. NET Ajax Brushless New technology
- A brief analysis of Ajax development Technology in Rails system (4)