I will launch the AJAX original series tutorial in the Web circle, if you don't know what Ajax is, please read: What is AJAX?
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:
<textarea id="runcode38860"><ptml> <pead> <title> Create an available Xmlhttpreuqest object </title> </pead> <body> <SCR IPT type= "Text/javascript" > Function ajax_xmlhttp () {//create XMLHttpRequest in IE, applicable to all versions of IE5.0 above 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; }//Loops create XMLHTTP based on IE browser. End//If not IE browser, create XMLHttpRequest if (!_xmlhttp && typeof XMLHttpRequest based on Firefox etc browsers) != "undefined") {_xmlhttp=new XMLHttpRequest (); return _xmlhttp; Alert (Ajax_xmlhttp ()); </script> </body> </ptml></textarea>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
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.
Copy Code code as follows:
<%
' 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 hold the XML data
Dim xml
XML = "<?xml version= ' 1.0 ' encoding= ' 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
%>
Well, today's Ajax tutorial preparations have been completed. The next one we will be small test--ajax reading data