未捕获的TypeError:无法读取未定义的属性“submit”

时间:2014-04-21 20:46:09

标签: javascript php

当我检查chrome中的元素时,这是html

<html>
    <head> 
        <title>Please Wait</title>
        <link rel="shortcut icon" href="images/ajax-loader1.gif" type="image/x-icon">
        <style type="text/css">

        </style>
    </head>
    <body onload="autoSubmit();" cz-shortcut-listen="true">
        <div>  
            <p class="header">Please Wait... Your Payment Request is being processed......</p>
           <p class="image_style">
               <img src="images/ajax-loader.gif">       
           </p>       
           <ul>    
               <li>This is a secure payment gateway using 256 bit SSL encryption</li>        
               <li>When you submit the transaction, the server will take about 1 to 5 seconds to process, but it may take longer at certain times </li>
               <li>Please do not press "Back" or "Refresh" buttons</li>
           </ul>        
        </div>

        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
        <title>Card Request</title>
        <script type="text/javascript">
          function autoSubmit()
          {
              document.card_processing.submit();
          }
        </script>
    </body>
</html>

我将一些值发布到给定的网址,并从那里使用以下自动提交重定向。有时这个页面有时会加载它。问题是什么?

这是我从控制台获得的

Uncaught TypeError: Cannot read property 'submit' of undefined 

2 个答案:

答案 0 :(得分:0)

通过添加表单来替换您的代码:

<body onload="autoSubmit();" cz-shortcut-listen="true">

  <form name="card_processing">

    <div>  
          <p class="header">Please Wait... Your Payment Request is being processed......</p>
          <p class="image_style">
            <img src="images/ajax-loader.gif">      
          </p>        
          <ul>    
            <li>This is a secure payment gateway using 256 bit SSL encryption</li>        
            <li>When you submit the transaction, the server will take about 1 to 5 seconds to process, but it may take longer at certain times </li>
            <li>Please do not press "Back" or "Refresh" buttons</li>
         </ul>        
    </div>

  </form>

但我认为您需要一个显示进度状态的重定向页面:

实现不需要表格或任何关于身体负荷的脚本

使用元刷新标记:

<meta http-equiv="refresh" content="5; ,URL=<redirect_url>">

这将在5秒后重定向页面......

答案 1 :(得分:0)

因为您正在处理javascript以提交表单:

明智地等待直到 脚本加载

document.addEventListener("DOMContentLoaded", function(){
  // Handler when the DOM is fully loaded
});

For more detail.

相关问题