数据是在$。员额迷路 [英] Data is getting lost during $.post

查看:71
本文介绍了数据是在$。员额迷路的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个列表< UL> 文章<李> 和一个按钮的事件处理程序

I have a list <ul> of articles <li> and an event handler on a button.

点击按钮时,我集中所有的&LT;李&gt;使用的ID(整数):

When clicking the button, I aggregate all <li>s ID (integer) using:

data.articles  = $('#category-articles').sortable('toArray');

// alerts 1298
alert(data.articles.length);

$.post(....);

在服务器端:

On the serverside:

<?php
// echoes 968
echo sizeof($_POST['articles']);

,明确:

  • 要发送的 1298 在数组中的项目 data.articles
  • 仅接收第一的 968 在数组中的项目 $ _ POST ['文章']
  • trying to send 1298 items in an array data.articles
  • receiving only the first 968 items in an array $_POST['articles']

数据是越来越POST操作过程中丢失。有实际的职位和目标PHP,可以过滤或删除任何项目之间没有code。

Data is getting lost during post action. There is no code between the actual post and the target PHP that could filter or remove any items.

我使用的Apache和PHP 5.3。

I'm using apache and PHP 5.3.

要求:

Content-Length: up to 80,000 bytes

服务器:

post_max_size = 100M
upload_max_filesize = 100M

我启用了错误报告功能,但它只是缩小我的数组,我不明白为什么它不发送的全部数据。任何人有一个想法?

I enabled error reporting but it just shrinks my array and I don't get why it doesn't sent the full data. Anyone has an idea?

推荐答案

的<一个复制href="http://stackoverflow.com/questions/12462840/array-being-chopped-off-over-ajax-post-ajax-posting-limit">Array被砍掉了阿贾克斯后结束。阿贾克斯发布的限制??

显示,它的做用PHP的max_input_vars:
此限制仅适用于多维输入数组的每一层嵌套。

Suggests that it's to do with PHP's max_input_vars:
This limit applies only to each nesting level of a multi-dimensional input array.

要解决这个问题,而无需编辑服务器配置:

To solve this without editing the server configuration:

// Serialize the elements into a single var using join():

data.articles  = $('#category-articles').sortable('toArray').join(';');

而在服务器端:

And on the serverside:

// Unserializing the single variable back into an array:

$articles = explode(';', $_POST['articles']);

而分隔字符; 必须不显示的元素中,选择了不同的角色,如果这是一个问题。

The delimiting char ; must not appear inside the elements, chose a different character if it is a problem.

这篇关于数据是在$。员额迷路的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆