dqfr90979
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() {
            $("input[name='field']").val(generatedUrl);
        });

The PHP :

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

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" />
</form>

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 :

    <script>
        $(function() {
            $( "#dialog" ).dialog();
        });
    </script>
    
    
    
    <div id="dialog" title="Basic dialog">
        <p><?php echo $xml;?></p>
    </div>
    
    已采纳该答案
    打赏 评论

相关推荐 更多相似问题