Ajax begins to prepare articles _ajax related

Source: Internet
Author: User
Tags prepare xml example
Before this we need to do a simple AJAX preparation, but you have to have the basic html,javascript,dom writing ability. Otherwise this Ajax tutorial will be hard for you to read. My goal is to pass this tutorial. Allows you to use AJAX technology in your Web pages to implement, read, add, modify, and delete data operations. Maybe you're an old bird that's dismissive of what I've written, but I'd like you to look at some of the examples that are shown in this tutorial, and there might be places to attract you!
Here's what we're going to do with 2 points. 1th We must create an available XMLHttpRequest object, if you do not know what is XMLHttpRequest, please read: What is XMLHttpRequest?
Because each big browser to the XMLHttpRequest object support standard is different, the so-called usable Xmlhttpreqeust object. This means that you want to run the object without errors in browsers such as Ie,ff,chrome. We use JavaScript to create the object and write a function. We will use this function to invoke XMLHttpRequest in a later instance of the Ajax tutorial. Look at the following code:
Copy Code code as follows:

<title> Create an available Xmlhttpreuqest object </title>
<body>
<script type= "Text/javascript" >
function Ajax_xmlhttp () {
Create XMLHttpRequest in IE, suitable for all versions above IE5.0
var msxmlhttp = new Array ("msxml2.xmlhttp.5.0", "msxml2.xmlhttp.4.0", "msxml2.xmlhttp.3.0", "Msxml2.xmlhttp", " Microsoft.XMLHTTP ");
for (var i=0; i<msxmlhttp.length; i++) {
Try
{
_xmlhttp=new ActiveXObject (Msxmlhttp[i]);
}
catch (E)
{
_xmlhttp=null;
}
//loop to create XMLHTTP based on IE browser. end
If not IE browser, create a browser based on Firefox XMLHttpRequest
if (!_xmlhttp && typeof XMLHttpRequest!= "undefined")
{
_xmlhttp=new XMLHttpRequest ();
}
return _xmlhttp;
}
Alert (Ajax_xmlhttp ());
</script>
</body>

After running the above code. In IE browser will pop "object", in FF and Chrome browser will pop "object XMLHttpRequest" words, if the correct pop-up is the XMLHttpRequest object to create success!
2nd: We use ASP technology to output an XML file. In a later example of an AJAX tutorial. We will request the file for Ajax read, add, delete, modify the operation of the data. Maybe you don't know yet. We can use any of the server's languages to output data in XML format. For example, we use ASP to read data from a table in a database and then output the data in the table as an XML file format to the client. This is the most standard way to use Ajax! Click to view: ASP output XML Format data
The following is the source code of the ASP file, you can copy it to your computer for testing.
<% ' from: Http://Www.Web666.Net ' author: Kang Dong ' If you want to reprint please be sure to keep the above information ' define a variable to save the XML data Dim xml = ' <?xml version= ' 1.0 ' Encodin g= ' gb2312 '?><body> "xml = xml&" <msg> a simple ASP output XML example, later in our Ajax tutorial instance, we will use this file for data reading operations </ Msg> "xml=xml&" </body> "Response.Clear response.contenttype=" Text/xml "response.charset=" gb2312 " Response.Write XML Response.End%>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

Well, today's Ajax tutorial preparations have been completed. Tomorrow we'll try a little--ajax. Read the data
Originated from: Http://Www.Web666.Net
Author: Kang Dong
Related Article

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.