Home  >  Article  >  Web Front-end  >  jquery ajax transmission of garbled Chinese parameters and explanation of solutions_jquery

jquery ajax transmission of garbled Chinese parameters and explanation of solutions_jquery

WBOY
WBOYOriginal
2016-05-16 17:01:10912browse

jQuery transmits garbled Chinese parameters. The reason is that the default transmission method does not use UTF-8. Therefore, we can encode the parameters when passing them, and then operate them. The code is as follows. The red code is the passed parameter. Mark

Copy code The code is 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" );
                                                       ; 🎜>                                                                                                                                                                                                                                                                    . || zjnum == "")
{
alert("Please enter the ID number");
return false;
}
if(zjnum.length > 30)
{
         alert("Sorry, there is something wrong with your ID, please re-enter"); ");
                                                                                          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",
                                                                                                                                                                      🎜>        })
       }
})

}


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn