jQuery的:把网址中的成功功能 [英] jQuery: get url in success function

查看:112
本文介绍了jQuery的:把网址中的成功功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从一个jQuery成功函数获取URL,它retreives数据从服务器后。不幸的是,这三个参数的成功函数采用不公开的原始地址:

I would like to get the url from a jQuery success function, after it retreives data from the server. Unfortunately, the three parameters the success function takes don't expose the original url:

成功:功能(数据,状态文本,jqhxr)

我甩了jqhxr变量,找不到网址在那里。我需要的URL的原因是因为我通过一个循环进行多个通话一次,所以我不知道这Ajax调用回来。使它成为一个异步调用没有帮助。

I dumped the jqhxr variable, and couldn't find the url in there. The reason I need the url is because I'm making several calls at once through a loop, and therefore I have no idea which Ajax call is coming back. Making it an asynchronous call didn't help either.

感谢你在前进!

推荐答案

this.url 内成功功能将工作,因为指的是功能的当前背景下,并且由于成功功能的设置部分对象,你传递给阿贾克斯()将访问url属性。

this.url inside success function will work because this refers to the current context of the function, and since the success function is part of the settings object that you're passing to .ajax() it will access the url property.

看到一篇文章,描述 JS范围和的。阿贾克斯()

See an article describing js scope and .ajax().

这篇关于jQuery的:把网址中的成功功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆