-4

当我们使用$_REQUESTinPHP接收 post/get 值时,我正在寻找一个类似的函数/键来接收values通过$.ajax.. in java script/j query

例子:

<script>

function do_something(){
// here i want the value sent using ajax
return term;
}

$('#input').keyup(function(){
var term=$(this).val();
$.ajax({
url:do_something(),// << is this possible?? or should i try 
//url:do_something(term)  //<< this???
dataType:'json',
data:{term:term},
results:function(data){
alert(JSON.stringify(data));
}
});

</script>
4

1 回答 1

-2

document.location.search可以获取当前 URL 的 GET 值。

像这样使用时:

document.location.search.substr(1).split("&");

您可以获得一个包含所有 GET 键和值的数组,例如key=value. 然后通过简单地将它们拆分,=您可以获得价值。

于 2013-10-22T10:03:20.647 回答