dongsi7067 2013-06-06 22:14
浏览 125

成功后,Jquery Ajax NyroModal页面重新加载

I have site running Jquery, Ajax, PHP, and an HTML form. It uses two pages.

Pages...

Example.php & Processexample.php

When you click the edit button on example.php a form pops up in the NyroModal window posting to Processexample.php and allows you to edit customer data that's posted using Ajax.

After user clicks save on Porcessexample.php a SQL update is made and a success message is posted back to the Modal Box (end-user).

Here are the issues...

  1. I can't get the NyroModal window to close after (data) success is called on processexample.php. I tried setting the Timeout in JQ/Javascript below but error occurs.

setTimeout("$.nyroModal.close()", 4000);

  1. How do i get example.php page to display updated data automatically, or have the page reload after #send button is clicked and success is displayed in modal window.

HTML Form Code on processexample.php

<form id="AjaxForm" name="AjaxForm" action="#" method="post">

<input name="submitform" type="hidden" value="1" 

<button id="send">Save Client</button>

JS Code on processexample.php --> See bold text in code where issue is.

    $(document).ready(function() {


    $("#AjaxForm").submit(function() { return false; });


    $("#send").on("click", function(e){

        var idval    = $("#client").val();
        var calval    = $("#view").val();
        var emailval  = $("#customer_email").val();
        var nameval   = $("#customer_name").val();
        var phoneval  = $("#customer_phone").val();


        var msgval    = $("#customer_note").val();
        var msglen    = msgval.length;
        var mailvalid = validateEmail(emailval);


        if(mailvalid == true && msglen >= 4) {
            // if both validate we attempt to send the e-mail
            // first we hide the submit btn so the user doesnt click twice
            $("#send").replaceWith("<em>sending...</em>");

            $.ajax({
                type: 'POST',
                url: 'saveclient.php',
                data: $("#AjaxForm").serialize(),
                success: function(data) {
                    if(data == "true") {
                        $("#AjaxForm").fadeOut("fast", function(){
                            $(this).before("<p><strong>Success! Your information has been updated.</strong></p>");
                            **setTimeout("$.nyroModal.close()", 4000);**
                        });
                    }
                }
            });
        }
    });
});
</script>
  • 写回答

1条回答 默认 最新

  • doushi6864 2013-06-07 02:16
    关注

    I was able to work this out myself. Use location.reload(); after the success call.

    评论

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?