所以我使用这个表单提交到 PHP 文件。PHP 文件有一个重定向标头,当我直接在浏览器中调用 php 文件时,它可以工作,但是当通过表单中的 action 属性访问它时,它什么也不做。曾经有一段时间我可以让它在不刷新的情况下重定向:2,但随后出现的问题是它只在 php 文档本身中包含重定向的文件,所以我的 javascript 和提交函数会失败......奇怪吗?请指教!这是怎么回事?
HTML
<form name="ats_routing" id="ats_routing" method="post" action="php/upload.php" enctype="multipart/form-data">
<!-- Some html generated by codiqa -->
<a onclick="submitForm();" data-transition="flip" data-theme="" data-icon="check">
Submit
</a>
</form>
Javascript 部分
/****CREATE JQUERY SUBMIT FUNCTION FOR IFRAME VALIDATION CHECK FOR Codiqa****/
function submitForm() {
if ($("#ats_routing").valid()) {
//alert("Thank You. Your Routing Form Has Been Submitted.");
$('#ats_routing').submit();
}
}
表单重定向到的 PHP (upload.php)
<?php
header("Refresh: 2; URL=/ats-routing/"); /* Redirect browser */
//Parse and store the db ini file, this will return an associative array
db_config_ats_ibutton();
db_connect();
$total_weight = $_POST['total_weight'];
$uf = $_POST['number_uf'];
$query="INSERT INTO datbasae (
lbs_uf,
total_weight,
district)
VALUES(
'$uf',
'$total_weight',
'$district')";
query_db($query);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<title>ATS Routing</title>
<link rel="stylesheet" href="https://d10ajoocuyu32n.cloudfront.net/mobile/1.3.1/jquery.mobile-1.3.1.min.css">
<link rel="stylesheet" href="http://dev.rs.idmyasset.com/ats-routing/css/theme.css">
<!-- Extra Codiqa features -->
<link rel="stylesheet" href="https://codiqa.com/view/bb40208d/css">
<!-- jQuery and jQuery Mobile -->
<script src="https://d10ajoocuyu32n.cloudfront.net/jquery-1.9.1.min.js"></script>
<script src="https://d10ajoocuyu32n.cloudfront.net/mobile/1.3.1/jquery.mobile-1.3.1.min.js"> </script>
<meta http-equiv="refresh" content="2; url=http://dev.rs.idmyasset.com/ats-routing/">
</head>
<body>
<!-- Home -->
<div data-role="page" id="page1">
<div id="header" data-theme="" data-role="header">
<h3 id="header">
ATS Routing Data
</h3>
</div>
<div data-role="content">
<h1 align="center">Thank You</h1>
<h1 align="center">Your Form Has Been Submitted!</h1>
</div>
</div>
</body>
</html>