JQuery passed Chinese parameters garbled, because the default transfer method is not using UTF-8, all we can pass the parameter encoding, and then operate, the Code is as follows, the red code is the passed parameter, marked
Copy codeThe 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 ("Enter your real name ");
Return false;
}
If (name. length> 20)
{
Alert ("sorry, your user name has an exception. Please enter it again ");
$ ("# Txt_name"). focus ();
$ ("# Txt_name"). val ("");
Return false;
}
If (zjnum = null | zjnum = "")
{
Alert ("Enter your ID card number ");
Return false;
}
If (zjnum. length> 30)
{
Alert ("sorry, your credential is abnormal. Please enter it again ");
$ ("# Txt_num"). focus ();
$ ("# Txt_num"). val ("");
Return false;
}
Else
{
$. Ajax ({
Type: "get ",
Cache: false,
ContentType: "application/x-www-form-urlencoded: charsets = UTF-8 ",
Url: "ajaxpage. aspx? T = smrz & name = "+ escape (name) +" & zjtype = "+ escape (type) +" & zjnum = "+ escape (zjnum) + "",
DataType: "json ",
Success: function (data ){
Alert (data.info );
}
})
}
})
}