简体   繁体   English

ajax调用中的GET参数(进入模式对话框)

[英]GET parameters on ajax call (into modal dialog)

On an html page i click on a link and i get a dialog which loads server content through an ajax call. 在html页面上,我单击一个链接,然后出现一个对话框,该对话框通过ajax调用加载服务器内容。

I cannot change the javascript that created this dialog neither the ajax callbacks . 我既不能更改创建此对话框的JavaScript,也不能更改Ajax回调。

I have the need to access the href of the clicked link from another javascript to change some content loaded into the dialog from the ajax call. 我需要从另一个JavaScript访问单击链接的href,以更改从ajax调用加载到对话框中的某些内容。 This after the dialog shows up. 对话框出现之后。

As i can only read the window.location of the current page (the page containing the dialog, not the page loaded into the dialog itself), is there a way to get the href of the clicked link that caused the dialog to show up ? 由于我只能读取当前页面(包含对话框的页面,而不是加载到对话框本身的页面)的window.location,有没有办法获取导致对话框显示的单击链接的href? (ie. the GET parameters of the ajax call) (即ajax调用的GET参数)

Attaching a callback for every clicked link doesn't work reliably because i have to catch just the last one that caused the dialog to open... 为每个单击的链接附加一个回调无法正常工作,因为我必须仅捕获导致对话框打开的最后一个...

-- edit -- -编辑-

Well i'm using jquery, but i don't think it's implementation dependant. 好吧,我正在使用jquery,但我不认为这取决于实现。

The question more generally is: if i cannot access the ajax callback, is there a way to obtain the url in the GET request that caused a div (some content) to update ? 更普遍的问题是:如果我无法访问ajax回调,是否可以在GET请求中获取导致div(某些内容)更新的网址? (assuming you can call a javascript function after the div is loaded, inside it). (假设您可以在div加载在其中调用javascript函数)。

ie. 即。 if it was a popup (window.open) i just have to read window.location to get the page called, but as it's a div loaded from an ajax request, how i can get the url called ? 如果它是一个弹出窗口(window.open),我只需要阅读window.location即可得到被调用的页面,但是由于它是从ajax请求中加载的div,我如何才能获得称为的URL?

thanks anyway~ 还是谢谢你〜

  1. Install Firefox (if you do not have it already) 安装Firefox(如果尚未安装)
  2. Install Firebug extension 安装Firebug扩展
  3. Enable firebug for your site 为您的网站启用Firebug
  4. Click the Link that launches the dialog (reproduce the situation) 单击启动对话框的链接(重现情况)
  5. Open the firebug window (bottom right corner of firefox) 打开萤火虫窗口(firefox的右下角)
  6. Under Net - >XHR tab you can see the exact URL call with all GET/POST parameters that was triggered. 在网络-> XHR选项卡下,您可以看到包含所有已触发的GET / POST参数的确切 URL调用。

Then explore firebug some more to see what other possibilities it offers! 然后再探索萤火虫,看看它提供了什么其他可能性!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM