【发布时间】:2016-10-03 09:19:37
【问题描述】:
我试图发布一个包含 500 多个数据字段的 php 表单。我尝试通过 jquery 序列化表单数据,然后提交表单。我也得到了同样的结果。谁能帮我解决这个问题。
【问题讨论】:
-
你使用的是
GET方法还是POST? -
在发送 500 请求之前检查过几个帖子?
-
发布我正在使用 Alok 的方法
我试图发布一个包含 500 多个数据字段的 php 表单。我尝试通过 jquery 序列化表单数据,然后提交表单。我也得到了同样的结果。谁能帮我解决这个问题。
【问题讨论】:
GET方法还是POST?
您可以使用JQuery 发布一个和一个值,然后将值保存在会话数组中。
在你的首页你会这样做:
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script>
function update_post(){
$("#/*Text Input ID Name*/").load("update_post_session.php?name=(session_array_name)&group=(session_name)&value="+ document.getElementById('Text Input ID').value.split(" ").join("_")); // .split(" ").join("_") does replace ALL spaces with underscores, this line can be used more times with different ID and value and name etc
}
// To update the session automaticly
setInterval(update_post, 10000); // This will update the form each 10 seconds, if you have over 500 inputs I would recommend minimum 5 seconds so it will not cause the client to experience any downtime to form
</script>
在您的 update_post_session.php 中,您将拥有:
<?php
session_start();
$session_group = $_GET['session_name'];
$session_name = $_GET['name'];
$value = $_GET['value'];
/*Replacing "_" with " "*/ $value = str_replace("_", " ", $value);
$_SESSION[$session_group][$session_name] = $value;
?>
编辑
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script>
function update_post(stop){var id = 0;
var whileinter = setInterval(function(){
if(id>stop){clearInterval(whileinter);}
$("#"+id).load("update_post_session.php?name=(session_array_name)&group=(session_name)&value="+ document.getElementById('Text Input ID').value.split(" ").join("_")); // .split(" ").join("_") does replace ALL spaces with underscores, this line can be used more times with different ID and value and name etc
id++;
}, 1);
}
// To update the session automaticly
var inter = setInterval(update_post(500 /* the amount of input boxes you have */), 10000); // This will update the form each 10 seconds, if you have over 500 inputs I would recommend minimum 5 seconds so it will not cause the client to experience any downtime to form
</script>
在您的 html 中,输入您将要输入的表单,从 0 到要按订单发布的表单数量 (0 1 2 3 4 5 6 7 8 9 10 ... 20 ... 50 ... 200 。 .. 500
【讨论】: