Use of Ajax request $. Get Method

Source: Internet
Author: User

You can use the $. Get method of jquery to initiate Ajax requests in get mode. $. Get is a utility function of jquery.

Get method syntax

$. Get (URL, parameters, callback)

Parameters

 

URL

(String) The server resource address.

Parameter

(Object) parameters must be passed to the server. The format is "key/value ". It appends the query string to the URL.

Callback

(Function) is called when the request is complete. The function parameters are the response body and status in sequence.

Return Value

Xhr instance

Let's look at a simple example.

ClientCode:

 
<HTML xmlns = "http://www.w3.org/1999/xhtml">  

Main server code:

Protected void page_load (Object sender, eventargs e) {If (! Page. ispostback) {If (request ["ID"]! = NULL &&! String. isnullorempty (request ["ID"]. tostring () {response. write (getdata (request ["ID"]. tostring () ;}} protected string getdata (string ID) {string STR = string. empty; Switch (ID) {Case "1": Str + = "this is number 1"; break; Case "2": Str + = "this is number 2 "; break; Case "3": Str + = "this is number 3"; break; default: Str + = "warning other number! "; Break;} return STR ;}

RunProgram, Result

Use httpwatcher to intercept request information. If you select a number from the drop-down list, you can intercept the following request information.

When the $. Get method is used:

We can see that the parameter ID is appended to the URL address.

$. The get method initiates a GET request, which is mostly usedQuerySome information.

Download demo

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.