Tom Broucke
Tom Broucke

Reputation: 249

ajax post json to php not receiving all data

When I try to post to a php file, some data of JSON file are lost. I have a JSON-file with 1100 entries. On my server, I can only add 333 entries. On another server, I can add 1000 entries. Do I have to change my server configuration?

JSON File has 1100 entries (users)

Jquery:

$.post(
  'store.php',
  {json:usersJSON},
  {contentType: "application/json"}, 
  function() {
    alert(data);
  });

PHP:

$JSON = $_POST['json'];
echo json_encode($JSON);

on one server, this echoes 333 entries, on the other server, it echoes 1000 entries

Upvotes: 1

Views: 1092

Answers (3)

Tom Broucke
Tom Broucke

Reputation: 249

The problem was max_input_vars in my php.ini file. It was set to 1000. That means I could add a json-file with 1000 entries with one field, or 500 entries with 2 fields,...

I set max_input_vars to 5000, now I can post a json-file with 1666 entries with 3 fields.

Upvotes: 2

Johan
Johan

Reputation: 35194

This is probably due to your server's configuration. Check php.ini for the setting max_post_size and ensure that it is sufficiently large to post your data. Also check your web server settings - Apache has a LimitRequestBody directive which could be causing your problem. Finally, check your web server and PHP error logs to see if the large post is triggering any errors.

source

Upvotes: 0

Jesper Blaase
Jesper Blaase

Reputation: 2400

How large are your entries? It might be the server limiting your posts. Try looking at the post_max_size directive in php.ini

Upvotes: 0

Related Questions