Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 表单提交后在弹出对话框中显示成功消息_Php_Jquery_Jquery Ui_Jquery Ui Dialog - Fatal编程技术网

Php 表单提交后在弹出对话框中显示成功消息

Php 表单提交后在弹出对话框中显示成功消息,php,jquery,jquery-ui,jquery-ui-dialog,Php,Jquery,Jquery Ui,Jquery Ui Dialog,我不熟悉jQuery。我想在弹出对话框中打开表单。当用户提交表单时,应将表单数据插入MySQL数据库,并在对话框中显示成功消息 我可以用表单进行对话,但如何加载成功消息 <head> <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.1/themes/base/jquery-ui.css"> <script src="http://code.jquery.com/jquery-1.

我不熟悉jQuery。我想在弹出对话框中打开表单。当用户提交表单时,应将表单数据插入MySQL数据库,并在对话框中显示成功消息

我可以用表单进行对话,但如何加载成功消息

<head>
    <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.1/themes/base/jquery-ui.css">
    <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
    <script src="http://code.jquery.com/ui/1.10.1/jquery-ui.js"></script>
</head>
<body>
    <button id="dialog_trigger">open the dialog</button>
    <div id="dialog" style="display:none;" title="Dialog Title">
        <form id="form1">
            <input type='text' name='data' id='data'/>
            <input type='submit' id='submit'/>
        </form>
    </div>
    <script>
        $( "#dialog_trigger" ).click(function() {
            $( "#dialog" ).dialog( "open" );
        });
        $("#dialog").dialog({
            autoOpen: false,
            position: 'center' ,
            title: 'EDIT',
            draggable: false,
            width : 350,
            height : 200, 
            resizable : true,
            modal : true,
        });
        $( "#submit" ).click(function() {
        // help    
        });
    </script>
</body>
使用或类似工具通过AJAX调用提交数据

例如,您的数据输入点应该返回一些JSON编码的值

echo json_encode(array('message' => 'Thank you for your submission'));
现在,从JavaScript端使用返回的消息填充模式内容,如

$("#message").text(message);

改进了代码块格式,因为它有助于提高可读性。标题中不需要语言或库名称,因为它们是标记的一部分。另外,不要添加与问题无关的标记。这个不需要CSS标签。
$("#message").text(message);