0

对于我的一生,当单击“是”按钮时脚本不会执行时,我无法解决?

控制台中没有记录任何内容。

有人可以帮忙吗?!:)

小提琴在这里:http: //jsfiddle.net/MCam435/NYWg2/2/

HTML:

<div id="reqtalkdialog" title="Confirmation Required">
  Would you like to request contact?
</div>

<div id="reqtalk100006" style="display:block"><a href="#" class="reqtalk" id="100006">
<span class="reqtalk_b"> + Talk </span></a></div>

jQuery:

$("#reqtalkdialog").dialog({
   autoOpen: false,
   modal: true,
   buttons : {
        "Yes" : function() {
            var element = $(this);
            var I = element.attr("id");
            var info = 'id=' + I;

            $.ajax({
                type: "POST",
                url: "resource/talkrequest.php",
                data: info,
                success: function(){}
            });

            $("#reqtalk"+I).hide();
            $("#talking"+I).show();
            return false;

            $(this).dialog("close");           
            },

        "Cancel" : function() {
          $(this).dialog("close");
        }
      }
    });

$(".reqtalk").on("click", function(e) {
    e.preventDefault();
    $("#reqtalkdialog").dialog("open");
});
4

1 回答 1

2

You're returning false before closing the dialog.

Remove that line, and it works: http://jsfiddle.net/A6TbN/

$("#reqtalkdialog").dialog({
   autoOpen: false,
   modal: true,
   buttons : {
    "Yes" : function() {
        var element = $(this);
        var I = element.attr("id");
        var info = 'id=' + I;

        $.ajax({
            type: "POST",
            url: "resource/talkrequest.php",
            data: info,
            success: function(){}
        });

        $("#reqtalk"+I).hide();
        $("#talking"+I).show();
        // return false;            

        $(this).dialog("close");

        },

    "Cancel" : function() {
      $(this).dialog("close");
    }
  }
});

$(".reqtalk").on("click", function(e) {
    e.preventDefault();
    $("#reqtalkdialog").dialog("open");
});
于 2013-09-20T17:51:41.247 回答