Refreshing data within a page with XML

Source: Internet
Author: User
Tags add object html page client
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.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.