Getting started with Ajax

Source: Internet
Author: User

I will introduce the original ajax series tutorials in the Web circle. If you do not know what ajax is, please read: What Is ajax?
Before that, we need to make some simple ajax preparations, but you must have basic html, javascript, and dom compiling capabilities. otherwise, you will have a hard time reading this ajax tutorial. my purpose is to pass this tutorial. you can use ajax to implement, read, add, modify, and delete data on your webpage. maybe you are an old bird, but I still want you to take a look at some examples demonstrated in this tutorial. It may attract you!
Here are 2. 1st: we must create an available XMLHTTPRequest object. If you do not know what XMLHTTPRequest is, read: What is XMLHTTPRequest?
Because different browsers support different standards for XMLHTTPRequest objects, the so-called available XMLHTTPReqeust object. that is to say, you need to run this object without errors in IE, FF, Chrome and other browsers. we use JavaScript to create this object and write a function. in future ajax tutorial instances, we will use this function to call XMLHTTPRequest. see the following code:
<Html> <pead> <title> Create an available xmlhttpreuqest object </title> </pead> <body> </ptml>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
After running the code above, "Object" will pop up in IE browser, and "Object XMLHTTPRequest" will pop up in FF and Chrome browsers. If the pop-up is correct, it indicates that the XMLHTTPRequest Object has been created successfully!
2nd: We use Asp technology to output an xml file. in future ajax tutorial instances. we will all request this file for ajax reading, adding, deleting, and modifying data operations. maybe you still don't know. we can use any language on the server to output data in xml format. for example, we use Asp to read data from a database table, and then output the data from the table as an xml file to the client. this is also the most standard ajax usage! Click to view: asp outputs data in xml format
The following is the source code of the asp file. You can copy it to your computer for testing.
Copy codeThe Code is as follows:
<%
'From: http://Www.Web666.Net
'Author: Kang Dong
'The above information must be retained if reprinted
'Define a variable to save xml data.
Dim xml
Xml = "<? Xml version = '1. 0' encoding = 'gb2312 '?> <Body>"
Xml = xml & "<msg> a simple example of xml output by Asp. In our ajax Tutorial example, we will all use this file to read data </msg>"
Xml = xml & "</body>"
Response. Clear
Response. ContentType = "text/xml"
Response. CharSet = "gb2312"
Response. Write xml
Response. End
%>

Now, the preparation for the ajax system tutorial is complete. Next, we will try to read data through ajax.

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.