Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/78.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 - Fatal编程技术网

Php 表单提交后窗口打开不起作用

Php 表单提交后窗口打开不起作用,php,jquery,Php,Jquery,我有以下函数将值提交到mysql数据库。php ajax调用工作正常。但是在insert函数之后,它不会执行与window.open相关的代码,它应该转到index.html页面 function sendval(){ var tosubmit = validateForm(); if(tosubmit){ showprog(); // now create the json string to insert in the database var myData = {}

我有以下函数将值提交到mysql数据库。php ajax调用工作正常。但是在insert函数之后,它不会执行与window.open相关的代码,它应该转到index.html页面

function sendval(){
var tosubmit = validateForm();
if(tosubmit){
    showprog();

    // now create the json string to insert in the database
   var myData = {};
   myData.EmpName=localStorage.getItem("username");
   myData.LeaveType = $( "#leavetype option:selected" ).text();
   myData.LeaveStart = $('#txtFromDate').val();
   myData.LeaveEnd = $('#txtToDate').val();
   myData.ContactNum = $('#contactnum').val();
   myData.Comments = $('#Comments').val();
   myData.UsrMail = localStorage.getItem("usermail");
   myData.SupMail = localStorage.getItem("supmail");
   myData.Status = 'Submit';

    var myjson = JSON.stringify(myData);
    $.ajaxSetup( { "async": false } );
    $.ajax({
    method: "POST",
    url: "submitleave.php",
    data: {"points": myjson}
    })
    .done(function( msg ) {
        if(msg == 'Success') {
            alert("Submission successful");
        } else {
            alert("Could not sumbit - try again");
        }
        $.ajaxSetup( { "async": true } );   
        window.open("index.html","_self");
    }); 
  } else {
        alert("Please enter valid values before submitting the form");
  }

}
我尝试了几次迭代,但似乎没有得到错误

其他一些功能也不起作用

<header>XXXXX<br>
<br><input type="button" value="Logoff" id="logoff">
</header>

$('#logoff').click(function(){
   localStorage.clear();
   window.open("index.html","_self");
});
XXXXX

$(“#注销”)。单击(函数(){ localStorage.clear(); window.open(“index.html”,“_self”); });

在这方面,

不要使用
async:false
它会阻塞用户界面,这是一种糟糕的做法,现在浏览器供应商不推荐使用它