2012-06-15 08:52
浏览 62

打开一个jQuery ui对话框,并在表单提交后显示PHP Post响应

I have a jQuery based form which set a value of an hidden input field in a form. I retrieve this value after a form submit with php : $_POST['myinputvar'] (it's a generated url).

This retrieved var is an url to a XML file which I parse with SimpleXML function.

The goal is to display this result in a dialog box after the submission of the form and do my PHP stuff here

The code :

the jQuery to populate my input field :

        $('#myForm').submit(function() {

The PHP :

if (isset($_POST['field']))
  $xml = simplexml_load_file($_POST['field']);

The form :

<form action="http://www.mysite.com/index.php" id="myForm" method="post">
<input name="field" type="hidden" value='' /> 
<input id="submit" type="submit" value="ok" />

So how can I display my PHP part into a dialog box after submit?

Any help will be very appreciated! Thanks!

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • donglu3087 2012-06-15 09:04

    Since it seems you don't use AJAX, you can do it that way as statued in the doc :

        $(function() {
            $( "#dialog" ).dialog();
    <div id="dialog" title="Basic dialog">
        <p><?php echo $xml;?></p>
    打赏 评论

相关推荐 更多相似问题