Keywords: JS URL Chinese garbled
Front Code:
function Login () {$ (' #error_msg '). Hide (), var uname = $ ("#name"). Val (); var pwd = $ ("#password"). Val (); if (uname== "" | | uname== "user name") {$ (' #error_msg '). Text (' User name or password cannot be empty! '); $ (' #error_msg '). Show (); return false;} if (pwd = = "" | | PWD = = "password") { $ (' #error_msg '). Text (' username or password cannot be empty! '); $ (' #error_msg '). Show (); return false;} $.getjson ("User/login", {Loginname:encodeuri (uname), Password:md5 (PWD), Passwordwy:pwd,ran:math.random ()}, function (Result) { if (result.flag== "false") { $ (' #error_msg '). Text (result.returnmsg); $ (' #error_msg '). Show (); return; } else { Cookie.setcookie ("UserName", result.returnmsg); Cookie.setcookie ("LoginID", Result.loginid); Cookie.setcookie ("UserId", result.id); Window.location.href= "index.html";}} );
Background code:
String loginId = Request.getparameter ("LoginName"); try {loginId = Urldecoder.decode (loginId, "UTF-8");} catch ( Unsupportedencodingexception E1) {e1.printstacktrace ();}
JS submitted at noon garbled processing encodeURI Urldecoder