使用jquery AJAX功能可以发送到服务器的数据量是否有限制?
我正在使用 jquery 提交表单,由于某些奇怪的原因,只有前 5 个变量被发送到 PHP 文件。代码如下:
$("form#alcs_submit").submit(function() {
var game_one = $('#game_one').val();
var game_two = $('#game_two').val();
var game_three = $('#game_three').val();
var game_four = $('#game_four').val();
var game_five = $('#game_five').val();
var game_six = $('#game_six').val();
var game_seven = $('#game_seven').val();
$.ajax({
type: "POST",
url: "mlb_alcs_edit.php",
data: "game_one="+ game_one +"& game_two="+ game_two +"& game_three="+ game_three +"& game_four="+ game_four +"& game_five="+ game_five +"& game_six="+ game_six +"& game_seven="+ game_seven,
success: function()
{
alert(game_six);
$('#bracket').load('mlb_alcs_changed.php?action=saved');
}
});
return false;
});
有什么建议吗?
谢谢,
兰斯
I'm using jquery to submit a form and for some bizarre reason, only the first 5 variables are being sent to the PHP file. The code is as follows:
$("form#alcs_submit").submit(function() {
var game_one = $('#game_one').val();
var game_two = $('#game_two').val();
var game_three = $('#game_three').val();
var game_four = $('#game_four').val();
var game_five = $('#game_five').val();
var game_six = $('#game_six').val();
var game_seven = $('#game_seven').val();
$.ajax({
type: "POST",
url: "mlb_alcs_edit.php",
data: "game_one="+ game_one +"& game_two="+ game_two +"& game_three="+ game_three +"& game_four="+ game_four +"& game_five="+ game_five +"& game_six="+ game_six +"& game_seven="+ game_seven,
success: function()
{
alert(game_six);
$('#bracket').load('mlb_alcs_changed.php?action=saved');
}
});
return false;
});
Any suggestions?
Thanks,
Lance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果其中一个值包含特殊的 URL 字符,那么它可能会破坏您的查询字符串。您应该在将这些值传递到查询字符串之前对其进行 URL 编码,如下所示:
此外,删除与符号之前的空格:
"& game_two=" + game_two
应该是"&game_two= " + game_two
或者,您可以通过传递对象而不是字符串,让 jQuery 将 POST 数据序列化为键/值对:
If one of the values contains a special URL character, then it can break your querystring. You should URL encode these values before passing them in they querystring, like this:
Also, remove the spaces before the ampersands:
"& game_two=" + game_two
should be"&game_two=" + game_two
Alternatively, you can let jQuery handle the serialization of your POST data into key/value pairs by passing an object instead of a string: