JQuery Ajax Get () function Read page

Source: Internet
Author: User

This article
Introduce the Get () function first:

Url,[data],[callback],[type]

Parameter description:

URL: The URL address of the page to be loaded

Data: Key/value parameter to be sent.

Callback: callback function when load succeeds.

Type: Returns the content format, XML, HTML, script, JSON, text, _default

Description

Get Way:

You can transfer simple data in Get mode, but the size is typically limited to 1KB, the data is appended to the URL (HTTP header transfer), that is, the browser appends individual form field elements and their data to the resource path in the request line in the format of the URL parameter. The most important point is that it is cached by the client's browser, so that other people can read the customer's data, such as account number and password, from the browser's history. Therefore, in some cases, the Get method poses a serious security problem.

First, establish a testget.php instance:

The code is as follows Copy Code

<?php
$web = $_get[' webname '];
echo "The website you are visiting now is:". $web;
?>


However, the establishment of the ajax.html file:

The code is as follows Copy Code


<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">
<script type= "Text/javascript" src= "/jquery-1.7.1.min.js" ></script>
<script>
$ (document). Ready (function () {
$ ("#btn"). Click (function () {
$.get ("testget.php", {web: "www.111cn.net"},function (data,textstatus) {
$ ("#result"). Append ("Data:" +data);
$ ("#result"). Append ("<br>textstatus:" +textstatus);
});
});
});
</script>
<body>
<input type= "button" value= "Test" id= "btn"/>
The contents of <div id= "Result" ></div>
</body>

You need to be aware of using get methods:

1 for Get requests (or any that involve passing parameters to the URL), the passed parameters are processed first by the encodeURIComponent method. Example: var url =

The code is as follows Copy Code
"Update.php?username=" +encodeuricomponent (username) + "&content=" +encodeuricomponent (content) + "&id=1";
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.