【问题标题】:Launch a post after a click on a jquery dialog button?单击jquery对话框按钮后启动帖子?
【发布时间】:2014-09-02 15:35:33
【问题描述】:

你们能告诉我这段代码有什么问题吗?为什么我的 JQuery UI 对话框中的删除按钮不会将帖子发送到控制器 url!

查看 HTML:

<a href="#" type="button" class="btn btn-default btn-lg" id="delete_button">
<span class="glyphicon glyphicon-remove-sign"></span> Supprimer les fichiers exportés</a>
<div class="dialog-message">
<div id="dialog-confirm" title="Supprimer les fichiers exportès ?">
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>Les fichiers exportés vont être supprimés définitivement de votre disque. Êtes-vous sûr de vouloir le faire ?</p>
</div></div>

查看 JQuery:

$('#delete_button').click(function () {
    $("#dialog-confirm").dialog({
        resizable: false,
        height: 200,
        width: 500,
        modal: true,
        buttons: {
            "Supprimer les fichiers": function () {
                /*$.ajax({async  : false, cache  : false, type   : "POST",
                url    : "index.php/site_ocr/delete_files",
                });*/
                $.post("index.php/site_ocr/delete_files");
            },
            Non: function () {
                $(this).dialog("close");
            }
        }
    });
});

【问题讨论】:

  • 您确定帖子网址正确吗?
  • 我用过 window.open($("index.php/site_ocr/delete_files")); ,同样的事情,我有按钮不要提交到下面的链接

标签: jquery codeigniter jquery-ui


【解决方案1】:
<a href="javascript(void(0))" type="button" class="btn btn-default btn-lg" id="delete_button">

希望这会有所帮助。

【讨论】:

  • 很好的答案附有代码示例,并为未来的读者提供了解释。虽然问这个问题的人可能理解你的答案,但解释你是如何得出这个问题的将帮助无数其他人。
【解决方案2】:

好像答案是这样的!

"Supprimer les fichiers": function() {
      window.location.replace("<?php echo base_url('index.php/site_ocr/delete_files'); ?>");
      $(this).dialog("close");
    },

我不得不重定向到我希望通过 javascript location.replace() 函数进行的操作:)

【讨论】:

    猜你喜欢
    • 2015-07-21
    • 2013-04-10
    • 2013-04-06
    • 1970-01-01
    • 1970-01-01
    • 2013-12-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多