Summer Fun giant-----Super simple/convenient-do not refresh the page---Refresh data-behind the---xmlhtt

Source: Internet
Author: User
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Super Simple/convenient-do not refresh the page---Refresh the data-behind---XMLHTTP---introduction/usage
+
+
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
--------------is the following very simple JavaScript function send (Str,url)----------------------
The XMLDOM and XMLHTTP objects are used. The benefits of this technology are: Full JS control, easy/simple, than RDS
Or remote is much better. (Prerequisite: Server-side and client must be installed IE5 or later), in my posted
The same technique is used for the No Refresh online information feature. Interested friends can see.
function Send (Str,url)
The str parameter is the incoming XML data, and you can also pass in other text data.
However, this function requires server-side processing to return the XML data, you can also modify
The URL parameter represents the ASP file address of the data you want to process
{
var Http = new ActiveXObject ("Microsoft.XMLHTTP")//Create XMLHTTP Object
var Dom = new ActiveXObject ("Microsoft.XMLDOM")//Create XMLDOM Object
Http.open ("POST", Url,false)
The first argument means that the data is sent in "POST". can be as large as 4MB, can also be changed to "get". Only 256KB
The 2nd parameter means which file the data is sent to processing
The 3rd parameter means synchronous or asynchronous mode. True is asynchronous, false is synchronous
Http.send (STR)//start sending the data ..... Doodle..
Dom.async=false//Set to get data synchronously
Dom.loadxml (Http.responsetext)
Starts getting the data returned after server-side processing. I'm here. Set must be XML data, otherwise error.
You can also modify it yourself. Make the return of the 2 or recordset data ......... ..............
if (Dom.parseError.errorCode!= 0)//check for errors when fetching data
{
Delete (Http)
Delete (Dom)
Return (false)
}
Else
{
var back = Dom.documentElement.childNodes.item (0). Text
Get the returned XML data, I'm here to assume that the handler returns only one row of XML data (a node)
Delete (Http)
Delete (Dom)
return (back)//function returns data .............. End

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.