Jquery get ($. get) event usage and Analysis

Source: Internet
Author: User

Definition and usage

The get () method loads information through a remote http get request. This is a simple GET request function to replace complex $. ajax. You can call the callback function when the request is successful. To execute a function when an error occurs, use $. ajax.

Syntax

$ (Selector). get (url, data, success (response, status, xhr), dataType)

Parameter description

The url is required. Specifies the URL of the request.
 
Data is optional. Specifies the data sent to the server together with the request.

Success (response, status, xhr) is optional. Specifies the function that runs when the request is successful.

Additional parameter descriptions:

Response-contains the result data from the request

Status-contains the Request status

Xhr-contains XMLHttpRequest object
 
DataType is optional. Specifies the expected server response data type. By default, jQuery can be intelligently judged.

Possible types include xml, html, text, script, json, and jsonp.

This function is short for Ajax functions and is equivalent:

$.ajax({  url: url,  data: data,  success: success,  dataType: dataType});

Instance used:

PHP file (http://www.phpernote.com/test.php) that returns data ):

<? Php $ arr = array (0 => array ('name' => 'qianyuqianxun ', 'Nick' => 'qianxun ', 'Contact '=> array ('website' => 'HTTP: // www.phpernote.com'), 1 => array ('name' => 'qisha ', 'Nick '=> 'seven shares', 'email' => 'yhm @ 163.com ', 'Contact' => array ('website' => 'HTTP: // www.baidu.com '); print_r (json_encode ($ arr [$ _ GET ['id'] [$ _ GET ['field']); exit;

The client obtains the following code:

$. Get ('HTTP: // www.phpernote.com/test.php', Region id:0,field:'name', function (data) {alert ('name: '+ data); // The result is qianyuqianxun });

Or:

$. Get ('HTTP: // www.phpernote.com/test.php', response id:0,field:'contact'response, function (data) {var dataObj = eval ("(" + data + ")"); alert (dataObj. website); // The result is: http://www.phpernote.com });
Articles you may be interested in
  • Jquery getJSON ($. getJSON) event usage and Analysis
  • Jquery load ($. load) event usage and Analysis
  • Jquery $. ajax $. post or $. get: How to submit the checkbox Value
  • Solution to failure of jquery live change event under IE
  • Common Values of Cache-control include private, no-cache, max-age, and must-revalidate.
  • JQuery-handle the latency of a hover event
  • Jquery simulates Mouse clicking events
  • JQuery retrieves page close events

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.