使用jquery在php中10秒后自动点击提交

I am trying to auto submit for after 10s in PHP using jquery. but no action is done.

I tried:

<?php echo "<div class="page-header">
            <h1 class="h2"></h1>
        </div>
        <script>
            var checkState = function(){
      jQuery.ajax({
        url: 'check_diffex.php?od=$scdate'
      }).done(function(data){
        if(data.diffex >= 10) {
        $('#quizsb').submit();          
      });    
    }    
    checkState();    
            </script>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jque‌​ry.min.js"></script>
    <form method="post" action="qform.php?srn=<?php echo $srn ?>&id=<?php echo $id ?>" enctype="multipart/form-data" class="form-horizontal" id="quizsb">
.....
</form
"?>

check_diffex.php

<?php

header('Content-Type: application/json');
if(isset($_GET['od'])){
    $deotd = $_GET['od'];
}
date_default_timezone_set('Asia/Calcutta');
$cdate = date('Y-m-d H:i:s ', time());
$scdate = strtotime($cdate);

$e = $scdate - $deotd;

// You would calculate a real value here
echo json_encode([
  'diffex' => $e
]);
?>

Before Answering Please look at this comment

use setTimeout function. Below code submit form automatically after 10sec from page load

<!DOCTYPE html>
<html>
<body>

<p>Enter some text in the fields below, then press the "Submit form" button to submit the form.</p>

<form id="myForm" action="/action_page.php">
  First name: <input type="text" name="fname"><br>
  Last name: <input type="text" name="lname"><br><br>
  <input type="button" onclick="myFunction()" value="Submit form">
</form>

<script>
    setTimeout(function(){ document.getElementById("myForm").submit(); }, 10000);
    
</script>

</body>
</html>

</div>

Use Cookie instead if you don't want user to increase timeout, so set Cookie with 10 seconds lifetime and delete the cookie after that. Please apply your logic to delete the cookie after 10 seconds and always check if the cookie is set or not, if it is not, then submit the form.

function setCookie(cname, cvalue, exdays) {
    var d = new Date();
    d.setTime(d.getTime() + (exdays * 24*60*60*1000));
    var expires = "expires="+d.toUTCString();
    document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}

function getCookie(cname) {
    var name = cname + "=";
    var ca = document.cookie.split(';');
    for(var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') {
            c = c.substring(1);
        }
        if (c.indexOf(name) == 0) {
            return c.substring(name.length, c.length);
        }
    }
    return "";
}