Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jqueryajax请求的url属性是否可以在done函数中访问?_Jquery - Fatal编程技术网

jqueryajax请求的url属性是否可以在done函数中访问?

jqueryajax请求的url属性是否可以在done函数中访问?,jquery,Jquery,我(在一个循环中)多次调用$.ajax,如下所示: var getRequest = $.ajax({ url: "http://maps.googleapis.com/maps/api/geocode/json?address=" + etc, type: "GET", dataType: "json", }); 我可以从getRequest.done函数中获取url属性(如上所示)函数的上下文是jqXHR(AJAX请求的包装器)。因此,您可以使用this $.ajax({ url:

我(在一个循环中)多次调用$.ajax,如下所示:

var getRequest = $.ajax({
url: "http://maps.googleapis.com/maps/api/geocode/json?address=" + etc,
type: "GET",
dataType: "json",
});

我可以从getRequest.done函数中获取url属性(如上所示)

函数的上下文是jqXHR(AJAX请求的包装器)。因此,您可以使用
this

$.ajax({
    url: "http://maps.googleapis.com/maps/api/geocode/json?address=" + etc,
    type: "GET",
    dataType: "json",
}).done(function () { alert(this.url) })

注意:如果“context”属性设置为“this”,它将不起作用。