2010-06-03 83 views
2

打开表单操作我有一个表格:如何jQuery的对话框

<form style="display: inline;" action="/player.php" method="post"> 
      <input type="hidden" name="recname" value="'.$row['name'].'"> 
      <input type="hidden" name="recordingdesc" value="'.$row['description'].'"> 
      <input type="hidden" name="reclink" value="$_SESSION['customerid'].'-'.$row['timestamp'].'.wav"> 

      <button type="submit" class="tooltip table-button ui-state-default ui-corner-all" title=" rec"><span class="ui-icon ui-icon-volume-on"></span></button> 
      </form> 

,我想player.php在一个模式对话框打开,并能够显示该发布信息如何才能做到这一点。

回答

2

Ajax就是答案。通过ajax发布表单并在回调函数中(如果发布成功),您可以创建对话框并加载从帖子返回的数据。查看关于Jquery.post

1

的jquery文档首先使用jquery-ui创建一个对话框。然后您需要ajax提交表格:

$("form button").click(function() { 
    $.post({url: '/player.php', data: $("form").serialize(), 
     success: function (data) { 
        $(div in dialog).html(data); 
        $("#MyDialog").dialog('open'); 
        } 
    }); 
    return false; 
});