Home >Web Front-end >JS Tutorial >Solution to the problem of garbled characters when using action on the page to pass parameters to the background_jquery

Solution to the problem of garbled characters when using action on the page to pass parameters to the background_jquery

WBOY
WBOYOriginal
2016-05-16 17:06:011334browse

Use jquery ajax on the page

Copy the code The code is as follows:

function createQS(name ){
var value = encodeURI(name);
var queryString = {key:value};
return queryString;
}

//Retrieve name method
function jiansuoByName(k,name){
if (name == '') {
alert("Please enter the search content");
return;
}
$.post(basePath "/sysmgr/searchesAjax/searchesJsonPlugin!searchesNameByOMCByName.action", createQS(name),
function(data){
//alert(data.result 'n ' k); // John
setLine_memoryFunction_A(data.result,k);
}, "json");
}


In the background action
Copy code The code is as follows:

import java.net.URLDecoder;

String _name = request.getParameter("key");
String name = URLDecoder.decode(_name,"utf-8");

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