Acoustic Jack
Acoustic Jack

Reputation: 117

Is there an ajax post size limit?

I'm converting an old MSAccess mdb. I'm trying to put data from the server into a 2D array and I think I'm going about it incorrectly.

This is a line from the JQuery on the main page

$.ajax({
    url: "clientlist.php", 
    type : "post",
    success: function(result){
        $("#div1").html(result);
    }
});

I'm just using #div for display before I try to put data into array.

And from 'clientlist.php'

$sql = "select * from tblContactTypes"; // 12 records
$records = mysqli_query($conn, $sql) or die("Error in the consult.." . mysqli_error($conn));

$rows = array();
while ($row = mysqli_fetch_assoc($records)) {
    $rows[] = $row;
}

echo json_encode($rows);

output in '#div1' is

[
{"ContactTypeID":"1","ContactType":"Personal"},
{"ContactTypeID":"2","ContactType":"Estate Agents"},
{"ContactTypeID":"3","ContactType":"Clients"},
{"ContactTypeID":"4","ContactType":"Suppliers"},

etc.

All working fine until I try a larger table ie. (php)

$sql = "select * from tblContacts"; //900 records

This just does not work! I've tried POST and GET but The Console Response is always blank on larger tables. There are 11 tables with varying numbers of records. It works with smaller tables but it won't even work with a table of 217 records and 11 fields!!!

I've been reading S/O and other forums for an answer and there are suggestions to do with 'config' files, but 'come on' not for a measly 200 records!!!

Surely this isn't a 'size' issue but I can't think of what else???

=============================================

Not sure if this should be 'edit' or 'answer'
I'm using XAMPP on Win 7.
I changed php.ini from...

post_max_size=8M

to...

post_max_size=200M

I tried several amounts between 8M - 200M but this didn't seem to affect things. I've half solved things by reducing number of fields in the sql and playing with 'limit'

Change from...

$sql = "select * from tblContacts";

to...

$sql = "select ContactID, ContactName from tblContacts limit 700";

and...

$sql = "select ContactName from tblContacts";

Nothing of any use in the PHP 'error log'. Next thing I'll do is look at 'error reporting'. ........

I came to this issue after using JQuery Autocomplete. http://jqueryui.com/autocomplete/
The data here is hardcoded and pretty small.

I looked around and found some stuff to play with ( can't remember exactly which one I chose or I would post a link, but there are plenty out there )
The one I chose called the server (through ajax) on every 'keyup' in the input box!.
This seemed like unnecessary traffic so I thought I would try to grab the lot in an array and then use this array for the autocomplete search.
That's how I got to where I am at the moment.

I've just looked back over the original code and noticed the ajax call uses a sql 'like' ...

$sql = "SELECT contactid,contactname,surname FROM tblcontacts WHERE contactname LIKE (:keyword)";

':keyword' is 'Post'ed through ajax and comes from the input box.
Obviously a lot less traffic so it all happens quickly enough.

I now think my comment about 'unnecessary traffic' might be wrong. I'm still pretty new to all this stuff so any comment from those more experienced would be welcome.
Thanks.

Upvotes: 0

Views: 1490

Answers (1)

underscore
underscore

Reputation: 6877

It's a server configuration. If you're working with PHP under Linux or similiar, you can control these using .htaccess, like so:

#set max post size
php_value post_max_size 20M

Upvotes: 1

Related Questions