jquery Ajax Transfer Chinese parameter garbled problem and solution explanation _jquery

Source: Internet
Author: User

jquery Pass the Chinese parameter garbled, because the default delivery method is not adopted UTF-8, all we can pass the parameters of the parameters of the code, and then operation, code as follows, the red code for the passed parameters, has been labeled

Copy Code code as follows:

Smsubmitclick = function () {
$ (document). Ready (function () {
var name = $ ("#txt_name"). Val ();
var type = $ ("#seltype option:selected"). Val ();
var zjnum = $ ("#txt_num"). Val ();
if (name = = NULL | | name = = "")
{
Alert ("Please enter your real name");
return false;
}
if (Name.length > 20)
{
Alert ("Sorry, your username is abnormal, please re-enter");
$ ("#txt_name"). focus ();
$ ("#txt_name"). Val ("");
return false;
}
if (Zjnum = null | | zjnum = = "")
{
Alert ("Please enter the identification number");
return false;
}
if (Zjnum.length > 30)
{
Alert ("Sorry, your document is abnormal, please re-enter");
$ ("#txt_num"). focus ();
$ ("#txt_num"). Val ("");
return false;
}
Else
{
$.ajax ({
Type: "Get",
Cache:false,
ContentType: "Application/x-www-form-urlencoded:charset=utf-8",
URL: "Ajaxpage.aspx?t=smrz&name=" +escape (name) + "&zjtype=" +escape (type) + "&zjnum=" +escape (zjnum) + "",
DataType: "JSON",
Success:function (data) {
alert (data.info);
}
})
}
})

}

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.