jquery Ajax URL parameter submission data instance

Source: Internet
Author: User

URL submission data is actually the get () method in Ajax

$get
URL (String): The URL address where the request is sent.
Data (MAP): (optional) The information to be sent to the server, expressed as a Key/value key-value pair, is appended to the request URL as querystring.
Callback (function): (optional) the callback function (which is invoked only if the response return state is success) when loading succeeds.

Cases

Use AJAX get requests to change the text of a DIV element:

The code is as follows Copy Code

<script type = "Text/javascript" src = ". /js/jquery.js "></script>
$ ("button"). Click (function () {
$.get ("Demo_ajax_load.txt", function (Result) {
$ ("div"). html (result);
});
});


One: URL parameter submission data

The code is as follows Copy Code

<script type = "Text/javascript" src = ". /js/jquery.js "></script>
<script type= "Text/javascript" >
function checkcorpid ()//Check if customer number is available
{
if ($.trim ("#txtF_CORPID") [0].value) = "")//txtf_corpid is the customer number input box
{
Alert ("Please enter customer number!");
}
Else
{
$ ("#checkFlag"). HTML ("detecting");//display of prompts
$.ajax ({
Type: "Get",
URL: "Checkcorpid.ashx",
Data: "Id=" +$.trim ($ ("#txtF_CORPID") [0].value),//Submit form, equivalent to Checkcorpid.ashx?id=xxx
Success:function (msg) {$ ("#checkFlag"). HTML (""); alert (msg); Operation after the successful operation! MSG is a backstage pass.
});
}
}
</script>

Background code:

The code is as follows Copy Code

if (context. request.params["ID"]. ToString ()!= "")
{
Pxt.Logic.SYS.CORP_BASE_INFO Cbil = new Pxt.Logic.SYS.CORP_BASE_INFO ();
BOOL Flag=cbil.checkcorpid (context. request.params["ID"]. ToString ());
if (flag)
{
Context. Response.Write ("The customer number is occupied!");
}
Else
{
Context. Response.Write ("The customer number is available!");
}
}


Attention matters

Ajax a coding is a problem, jquery ajax default is the URL for UFT8 encoding, so everyone can be unified under the code to appear free of Chinese garbled.

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.