Rookie Cai Ajax Review of the second article (The load () method in jquery to implement AJAX functionality) _ajax related

Source: Internet
Author: User
In the previous blog, I wrote about using XMLHttpRequest objects to load data asynchronously in traditional JavaScript, alas, children's shoes .... See the code is not a little headache ah! Not only you, I have a little disgusted, not only to judge the browser, but also ... Anyway, there is a big piece of code, looks not cool, now, let us forget to take a big Tuo bar (remember: Here is not really forget!) It seems like many companies interviewing Ajax this piece of content, you do not have to drag the control of the way to write an original eco-Ajax program, so its importance, you understand! )! Okay, so much so, you should "forget" you! Oh...... It's time to witness the miracle (whining ...). Don't say I'm bragging! This is not what I said, this Liu Qian said, what things to find him ah! )! In jquery, using the load () method can easily achieve the ability to get asynchronous loading data, now let a few lines of code instead of this big Tuo! (First, or as before, create 1.htm and 2.htm two pages first!) )

The code in 1.htm is as follows:
Copy Code code as follows:

<title></title>
<script src= "Scripts/jquery-1.4.1.js" type= "Text/javascript" ></script>/Note: Don't forget to add it!
<script type= "Text/javascript" >
$ (function () {
$ ("#btnGet"). Click (function () {//button clicks event
$ ("#divMsg"). Load ("2.htm");//Call Load () method; Load syntax format: Load (Url,[data],[callback]): Where URL is loaded page address, optional parameter data is to be sent to the service//service, the format is a key/value;callback after the successful loading, Return to the callback function that loads the page
})
})//Here must pay attention to Oh! Parentheses must be "in the same time" well, when you write more code, at this point inadvertently will be wrong!
</script>
<body>
<input type= "button" id= "Btnget" value= "Fetch data"/>
<div id= "Divmsg" >
</div>
</body>


The code in 2.htm is as follows:

Copy Code code as follows:

<title></title>
<body>
Name: Vegetable <br/>
Sex: Male <br/>
Email: cj1161059871@163.com
</body>


Finished, here hope the heroes do not laugh Ah! Because I originally is steer Cai, write out of thing is a bit two, just give yourself a review!
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.