从 html 发布表单,将服务器响应获取到 jquery 模态灯箱

发布于 2025-01-06 14:04:45 字数 437 浏览 1 评论 0原文

我的页面上有一个简单的 html 表单。

我正在使用 colorbox,尽管我想象任何 jquery lightbox 都可以 - 这里的问题是尝试将表单响应从服务器获取到 jquery lightbox。过去,您可以设置表单“目标”并将其指向 IFRAME。显然,由于 XSS 漏洞,我们现在不这样做,但是......

我们应该如何做到这一点?

有谁有可以分享的带有代码的工作示例吗?我不是在寻找“使用 xxxxx lightbox” - 或“使用 $.post - 我已经尝试过。要么灯箱未打开,因为它尚未以正确的方式实例化,要么它打开但它是空的并且可以”无法访问parent.document中的日期(足够公平)或来自服务器的数据我尝试在document.ready中实例化 - 但我需要它触发onsubmit,如果我在document.ready上触发它,则值不正确 - 即使事件。不应该那样工作,是吗?

I have a straightforward html form on a page.

I am using colorbox although I would imagine any jquery lightbox would do - the issue here is trying to get the form response from the server into the jquery lightbox. Back in the day you could set form "target" and point it at an IFRAME. Obviously we don't do that now because of XSS vulnerabilities BUT...

How are we supposed to do this?

Does anyone have a working example, with code, that they can share? I am not looking for "use xxxxx lightbox" - or "use the $.post - I have tried. Either the lightbox doesn't open because it hasn't been instantiated in the correct way or it opens but it's empty and can't access either the date in parent.document (fair enough) or data from the server. I try instantiating inside document.ready - but I need it triggering onsubmit and if I trigger it on document.ready the values are incorrect - even though events aren't supposed to work like that, are they?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

゛清羽墨安 2025-01-13 14:04:45
 $.post( url,
      function( data ) {

          // you have to open lightbox here.
          // and then you can fill it with result.

          var content = $( data ).find( '#content' );
          $( "#result" ).empty().append( content );
      }
    );

ajax 请求完成后,您必须打开灯箱。我认为您首先打开了灯箱,然后您无法通过后期响应轻轻地填充它,因为灯箱已经有宽度和高度。
这是我从你的帖子中了解到的。

 $.post( url,
      function( data ) {

          // you have to open lightbox here.
          // and then you can fill it with result.

          var content = $( data ).find( '#content' );
          $( "#result" ).empty().append( content );
      }
    );

you have to open lightbox when ajax request has been completed. I think you opened lightbox first and then you can't fill it up gently with post response since lightbox had width and height already.
This is what I understand from your post.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文