将灯箱更改为 Ajax 调用

发布于 2024-12-04 05:40:00 字数 378 浏览 4 评论 0原文

我正在尝试重写此链接,这样它不会链接到灯箱,而是进行 ajax 调用并更新

<div class="add-rule>"<a href = "/saffron_main/add_rule?type=tid&mid=0&cid=1&m-name=valid"  class="lightwindow" params="lightwindow_type=external,lightwindow_height=100,lightwindow_width=300">Add a rule</a></div>

我的 链接Javascript 和 Ajax 新手,因此我们将不胜感激。

I am trying to rewrite this link so instead of linking to a light box, it makes an ajax call and updates the contents of <div class = "add-rule>. Here is the link

<div class="add-rule>"<a href = "/saffron_main/add_rule?type=tid&mid=0&cid=1&m-name=valid"  class="lightwindow" params="lightwindow_type=external,lightwindow_height=100,lightwindow_width=300">Add a rule</a></div>

I am new to Javascript and Ajax, so any help would be much appreciated.

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

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

发布评论

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

评论(1

伴我老 2024-12-11 05:40:00

代码应该看起来像这样(无法检查这个,但我离得不远)
有关详细信息,请查看 jquery 的 ajax api
您可能对加载函数感兴趣。

这是我的代码,请告诉我是否合适

<div class="add-rule">
    <span id="addRuleError"></span>
    <a href="javascript:void(0)" onclick="loadContent()" class="lightwindow"
                         params="lightwindow_type=external,lightwindow_height=100,lightwindow_width=300">Add a rule</a>
</div>

        <script type="text/javascript">
            function loadContent()
            {
                $("#addRuleError").text("");
                $.ajax({
                    url:"saffron_main/add_rule",
                    data:{type:"tid", mid:0, cid:1, "m-name": "valid"},
                    success:function(result){$(this).parent().html(result)},
                    error:function(result){$("#addRuleError").html(result.responseText)}
                })
            }

        </script>

The code should look some like this (couldn't check this out but I am not far away)
For more info have a look at jquery's ajax api
and you might be interested in the load function.

This is my code, let me know if it fits or not

<div class="add-rule">
    <span id="addRuleError"></span>
    <a href="javascript:void(0)" onclick="loadContent()" class="lightwindow"
                         params="lightwindow_type=external,lightwindow_height=100,lightwindow_width=300">Add a rule</a>
</div>

        <script type="text/javascript">
            function loadContent()
            {
                $("#addRuleError").text("");
                $.ajax({
                    url:"saffron_main/add_rule",
                    data:{type:"tid", mid:0, cid:1, "m-name": "valid"},
                    success:function(result){$(this).parent().html(result)},
                    error:function(result){$("#addRuleError").html(result.responseText)}
                })
            }

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