jQuery Mobile弹出窗体提交通知

时间:2013-07-17 20:39:33

标签: php forms jquery-mobile

我有一个jQuery评论页面,我将数据提交到submit.php页面以通过电子邮件发送数据。截至目前,我已经成功进入了一个“成功”页面,但我宁愿(如果可能的话)当你在review.php上提交时,它会弹出一个通知让你知道它是邮寄还是回应错误。任何帮助都会很棒。

Review.php

    <script>
        function onSuccess(data, status)
        {
            data = $.trim(data);
            $("#notification").text(data);
        }

        function onError(data, status)
        {
            // handle an error
        }        

        $(document).ready(function() {
            $("#submit").click(function(){

                var formData = $("#callAjaxForm").serialize();

                $.ajax({
                    type: "POST",
                    url: "order.php",
                    cache: false,
                    data: formData,
                    success: onSuccess,
                    error: onError
                });

                return false;
            });
        });
    </script>

<form id="callAjaxForm">
                <ul>
                <?php


                    if (is_array($_REQUEST)) {
                        foreach ($_REQUEST as $key => $val) {

                            // This code should support the checkboxes and multiple selects
                            if (is_array($val)) {
                                foreach ($val as $val2) {
                                    echo "<input type='hidden' name='" . $key . "[]' value='" . $val2 . "' />";
                                }
                            }
                            else {
                                echo "<input type='hidden' name='" . $key . "' value='" . $val . "' />";
                            }
                        }
                    }
                ?>
                </ul>
                <div class="ui-body ui-body-b">
                    <fieldset class="ui-grid-a">
                        <button type="submit" data-theme="a">Submit</button>
                    </fieldset>
                </div>
            </form>

Submit.php

 if($from == '') {print "You have not entered an email, please go back and try again";} 
 else { 
 if($name == '') {print "You have not entered a name, please go back and try again";} 
 else { 
 $send = mail($to, $subject, $body, $headers); 
 $send2 = mail($from, $subject2, $autoreply, $body, $additional_headers); 
 $send3 = mail($name2, $subject2, $autoreply2, $additional_headers); 
 $result = 'success';

 if($send) 
 {echo json_encode($result);} 
 else 
 {print "We encountered an error sending your mail, please review your information"; } 
 }
}

0 个答案:

没有答案