xml| Data | refresh | page
Refreshing the (partial) data in a page without leaving the page benefits a lot. The main is no need to write boring code to maintain state. asp.net (and its embryonic VI6 SOM) in Server-side control (VI6 DTC, Script Library) through a large number of hidden input to maintain the page state, the depth of its ability, not hallowed be thy and. So we have to find a way to get new data without leaving the page,
1. XMLHTTP
This approach means similar to RDS, but in the XML age this approach is more serious.
There is a better example on the Web:http://www.asptoday.com/articles/20001219.htm
Using Fat Clients for E-commerce
The author's name (Fat client) means that browser is required to support XMLHTTP.
Code Snippets:
Function getcategories ()
Dim oxmlhttp "as Object"
Dim ocategories "as Object"
Set oxmlhttp = CreateObject ("Microsoft.XMLHTTP")
"---Set the XMLHTTP call and issue send (no parm as category
"---is included in URL
Oxmlhttp.open "Get", Server_path & "Demo.asp?action=getcategories", False
Oxmlhttp.send
"---Load the response into the Categories data island
Dsocategories.loadxml Oxmlhttp.responsetext
"---transform into HTML and assign to InnerHTML property
divcategories.innerhtml = DsoCategories.documentElement.transformNode (dsocategoriesxsl.documentelement)
"---tidy up the object
Set oxmlhttp = Nothing
End Function
In fact, the direct use of domdocument.load is the same.
Code Snippets:
var oxmldoc = new ActiveXObject ("MSXML");
sURL = "<%=strpathinfo%>xmlcity.asp?" State= "+ sstate;
Oxmldoc.url = sURL;
It is also possible to create activexobject without dominance, and the workaround is to use the <xml id= "MyData" >.
2. How to support Netscape browser?
In view of the XML SRC that can be used in the page to get XML data, we can take a closer look at the HTML properties:src.
You can notice that there is also a commonly used tag with this attribute-IFrame.
So we can use the following ideas to get data from the server, which we don't use XML Island, ActiveX Object, to support NN.
A. Add a hidden IFrame to the page.
B. When you need to invoke data, the statement is like: IFRAME.SRC = "http://localhost/getData?a=123"
C. In order to meet the appetite of NN, our return value is not direct XML Data, but HTML, which can be accepted by IFrame
D. But most importantly, this HTML Page is actually a well-formed XML document. Like what:
<HTML>
<BODY>
<p id= "P1" >abc</P>
<p id= "P2" >def</P>
<p id= "P3" >ghi</P>
</BODY>
</HTML>
E. We can use client-side JavaScript to grab the data from this well-formed XML Doc and add it to our select ListBox.