ajax请求后,将后台查询出的数据转换成json格式,接受后就可以在页面中可以用json.来获取数据
$.ajax({
type: 'post',
url: url ,
data: data ,
success: function(data){
window.location.href = 'b.html?id=data.id&name=data.name';
},
dataType: "json"
});
b.html中用js获取参数
/**网上找的**/
function GetRequest() {
var url = location.search; //获取url中"?"符后的字串
var theRequest = new Object();
if (url.indexOf("?") != -1) {
var str = url.substr(1);
strs = str.split("&");
for(var i = 0; i < strs.length; i ++) {
theRequest[strs[i].split("=")[0]]=(strs[i].split("=")[1]);
}
}
return theRequest;
}
var req = GetRequest();
var id = req["id"];
var name = req["name"];
console.log("id="+id +",name=" +name );
你在controller层,return到b页面不就完了?