我必须处理由Ajax Request调用的html页面上的请求参数。 我的代码是:
$.ajax({
type: "GET",
url: "abc.html",
data: "cat=1",
dataType: "html",
success: function(data) {
$("#div").html(data);
}
});
现在在abc.html页面上,我想使用“cat”请求参数。 怎么可能?
答案 0 :(得分:0)
希望此链接可以帮助您 - http://jquery-howto.blogspot.in/2009/09/get-url-parameters-values-with-jquery.html
function getUrlVars()
{
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
}