[JQuery tutorial] jquery getting started instance tutorial 3 ajax application

Source: Internet
Author: User
Tags http post

We are in the last chapter jquery Beginners Introductory example teaching two user registration (simple form verification) (/html/jqueryjiaocheng/200807/17-519.html)

There's a line of statements inside

$.get ("php/user_register.php", {act:$ (this). attr ("IDs"), v:$ (This). Val ()},function (TXT) {
msg.html (TXT);

})

This is a simple example of jquery ajax application

What is Ajax

Ajax is all called "Asynchronous JavaScript and XML" (Asynchronous JavaScript and XML), a Web development technology that creates interactive Web applications.

If you are not very clear please refer to http://baike.baidu.com/view/1641.htm

Now let's look at jquery's support for Ajax.

First, let's talk about $.get.

$.get (URL, params, callback)

Request Mount Remote page with Get method

return value: XMLHttpRequest

Parameters:

    • URL (String): The URL address where the page is loaded.
    • params (MAP): (optional) key/value pair parameters sent to the server.
    • Callback (function): (optional) functions that are executed when a remote page is loaded to completion.

Instance:
For example file Demo1 HTML code as follows
<a href= "javascript:void (0)" >demo</a>
<div id= "Show" style= "Border:solid 1px #FF6600" > added in Content:</div>

The get.html code is as follows
<strong>ajax Get content </strong>

Now I'm going to implement the click Demo to load the get.html content into the div.

<script language= "JavaScript" >
<!--
$ ("document"). Ready (function () {
$ ("a"). Click (function () {//div binding Sentinel Event
$.get ("get.html", function (data) {
$ ("#show"). HTML ($ ("#show"). HTML () + "<br>" +data);
})
})
})
-->
</SCRIPT>

If you need to take parameters only
$.get ("get.html", {parameter name 1: Parameter 1 value), parameter name 2: Parameter 2 value},function (data) {
$ ("#show"). HTML (data);
})

$.post (URL, params, callback)

mount a remote page in HTTP POST mode

return value: XMLHttpRequest

Parameters:

  • URL (String): The URL address where the page is loaded.
  • params (MAP): (optional) key/value pair parameters sent to the server.
  • Callback (function): (optional) functions that are executed when data is loaded into completion.
About $.post Demo I'm not going to write it. and $.get exactly the same just one is get way request one is post mode request
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.