jquery Ajax Transfer Chinese parameter garbled problem and solution explanation

Source: Internet
Author: User

  This article is mainly about the jquery Ajax transfer of Chinese parameters garbled problem and the solution is introduced, the need for friends can come to the reference, I hope to help you.

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 to encode, and then operation, the code below, the red code for the passed parameters, has been labeled     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 = = "")        {          & Nbsp;alert ("Please enter your real name");            return false;       &NBSP,        if (Name.length >)        {           alert ("Sorry, your username is abnormal, please re-enter");            $ ("#txt_name"). focus ();            $ ("#txt_name"). Val ("");            return false;       &NBSP}        if (zjnum = = NULL | | Zjnum = "")        {           alert ("Please enter the document number");            return false;       &NBSP,        if (Zjnum.length >)        {  &NBSP ;        alert ("Sorry, your documents are abnormal, please re-enter");            $ ("#txt_num"). focus ();            $ ("#txt_num"). Val ("");            return false;       &NBSP        else        {        &NBS P   $.ajax ({                type: "Get",           &NB Sp     Cache:false,                 ContentType: "Application/x-www-form-ur Lencoded: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);     &NB Sp           {           })       &NBSP}   &nbs P;})  }

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.