ajax.response max size

T

trpost

I am using ajax / php where I am looking up some info from the
database and populating a select list dynamically, however I am
running into some sort of size limitation with the ajax.response
object. If the string I am passing to javascript from php is too large
javascript does not get it all the data. The magic number appears to
be 6123 characters, anything below that it works fine, anything above
and if I alert the ajax.response, I see the string is cutoff. Any
ideas where this limitation is defined?
 
R

Randy Webb

(e-mail address removed) said the following on 2/23/2007 7:48 PM:
I am using ajax / php where I am looking up some info from the
database and populating a select list dynamically, however I am
running into some sort of size limitation with the ajax.response
object. If the string I am passing to javascript from php is too large
javascript does not get it all the data. The magic number appears to
be 6123 characters, anything below that it works fine, anything above
and if I alert the ajax.response, I see the string is cutoff. Any
ideas where this limitation is defined?

Probably implementation independent. But, if you are trying to pass 6K+
of data you are doing something wrong. That is a *lot* of data.
Especially for a select list.
 
Ú

ÚÑÈ ÒæÇÌ

ÈÓã Çááå ÇáÑÍãä ÇáÑÍíã


ÇÝÖá ãæÞÚ ááÊÚÇÑÝ Èíä ÇáÌäÓ íä ÇáÔÈÇÈ æÇáÈäÇÊ ãä ßá Ïæá ÇáÚÇáã
www.arabzwaj.com

ÈäÇÊ æÔÈÇÈ ÚÇíÒííä íÊÚÑÝæÇ Úáíßã


ÕæÑ ÚÇÑíÉ ÍÞíÞíÉ


ÊÚÇÑÝ ãÌÇäí ãä ßá Ïæá ÇáÚÇáã www.arabzwaj.com
for marrige and friend shipÇÝÖá ÊÚÇÑÝ Èíä ÇáÔÈÇÈ æÇáÈäÇÊ ãæÞÚ ÒæÇÌ
ãÌÇäí www.arabzwaj.com

www.arabzwaj.com ÇÝÖá ãæÞÚ ãÌÇäí ááÊÚÇÑÝ æ ááÒæÇÌ ÇáÔÑÚí

www.arabzwaj.com ÈäÇÊ æÔÈÇÈ ÚÇíÒå ÊÊÚÑÝ Úáíßã





the best web site formarrige and frindship www.arabzwaj.comÇÝÖá ãæÞÚ
ãÌÇäí ááÊÚÇÑÝ æ ááÒæÇÌ
 
Ú

ÚÑÈ ÒæÇÌ

ÈÓã Çááå ÇáÑÍãä ÇáÑÍíã


ÇÝÖá ãæÞÚ ááÊÚÇÑÝ Èíä ÇáÌäÓ íä ÇáÔÈÇÈ æÇáÈäÇÊ ãä ßá Ïæá ÇáÚÇáã
www.arabzwaj.com

ÈäÇÊ æÔÈÇÈ ÚÇíÒííä íÊÚÑÝæÇ Úáíßã


ÕæÑ ÚÇÑíÉ ÍÞíÞíÉ


ÊÚÇÑÝ ãÌÇäí ãä ßá Ïæá ÇáÚÇáã www.arabzwaj.com
for marrige and friend shipÇÝÖá ÊÚÇÑÝ Èíä ÇáÔÈÇÈ æÇáÈäÇÊ ãæÞÚ ÒæÇÌ
ãÌÇäí www.arabzwaj.com

www.arabzwaj.com ÇÝÖá ãæÞÚ ãÌÇäí ááÊÚÇÑÝ æ ááÒæÇÌ ÇáÔÑÚí

www.arabzwaj.com ÈäÇÊ æÔÈÇÈ ÚÇíÒå ÊÊÚÑÝ Úáíßã





the best web site formarrige and frindship www.arabzwaj.comÇÝÖá ãæÞÚ
ãÌÇäí ááÊÚÇÑÝ æ ááÒæÇÌ
 
J

Jeff North

| I am using ajax / php where I am looking up some info from the
| database and populating a select list dynamically, however I am
| running into some sort of size limitation with the ajax.response
| object. If the string I am passing to javascript from php is too large
| javascript does not get it all the data. The magic number appears to
| be 6123 characters, anything below that it works fine, anything above
| and if I alert the ajax.response, I see the string is cutoff. Any
| ideas where this limitation is defined?

Your page:
<select name="lbItems" onChange="AJAXCall(this.value);">
<option value="1">1</option>
etc etc etc
</select>

Javascript function on your page
function AJAXCall(val)
{
//--- make your ajaxcall here
url = "mypage.php?id=" + val;
}

php page:
<?php
$id = 0;
if( isset($_GET['id]) ) $id = $_GET['id'];
if( !is_numeric($id) ) $id =0;

//--- read database
$sql = "SELECT * FROM yourtable WHERE pk=".$id;

//--- loop through recordset and populate listbox
echo "<option value='".$recPK."'>".$recText."</option>\n";
?>
 
K

Kris Zyp

I frequently use Ajax requests with responses of 100K+ with no
problems for both IE and FF.
Kris

| I am using ajax / php where I am looking up some info from the
| database and populating a select list dynamically, however I am
| running into some sort of size limitation with the ajax.response
| object. If the string I am passing to javascript from php is too large
| javascript does not get it all the data. The magic number appears to
| be 6123 characters, anything below that it works fine, anything above
| and if I alert the ajax.response, I see the string is cutoff. Any
| ideas where this limitation is defined?

Your page:
<select name="lbItems" onChange="AJAXCall(this.value);">
<option value="1">1</option>
etc etc etc
</select>

Javascript function on your page
function AJAXCall(val)
{
//--- make your ajaxcall here
url = "mypage.php?id=" + val;

}

php page:
<?php
$id = 0;
if( isset($_GET['id]) ) $id = $_GET['id'];
if( !is_numeric($id) ) $id =0;

//--- read database
$sql = "SELECT * FROM yourtable WHERE pk=".$id;

//--- loop through recordset and populate listbox
echo "<option value='".$recPK."'>".$recText."</option>\n";
?>
 
P

pwiegers

I frequently use Ajax requests with responses of 100K+ with no
problems for both IE and FF.
Kris

On a related note: does anybody know how to /post/ more data at the
AJAX call? Normally, any parameters you use are in the URL. But I
would like to be able to post a lot of data to the server... any
idea's?

Paul
 
J

Jeff North

| > I frequently use Ajax requests with responses of 100K+ with no
| > problems for both IE and FF.
| > Kris
|
| On a related note: does anybody know how to /post/ more data at the
| AJAX call? Normally, any parameters you use are in the URL. But I
| would like to be able to post a lot of data to the server... any
| idea's?

http://ajaxtoolbox.com/request/examples.php

then scroll to Form Submittal.
 
T

trpost

Ok, Here is the code for what I am doing, and the ajax library being
used is SACK from http://twilightuniverse.com/projects/sack/ I just
can't seem to pass more than about 6100 characters... Any ideas, or a
better way to go?

<?php

//If some search criteria was sent
if(isset($_GET['searchCriteria']))
{

//////////////////////////////// DB
Connection ///////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////

include('./adodb/adodb.inc.php');

//Type of connection
$db = NewADOConnection('oci8');

//Sets the query results to come back as assoc arrays
$db->SetFetchMode(ADODB_FETCH_ASSOC);

//Make the connection
$db->PConnect('xxxxx', 'yyyyy', 'zzzzz');



//////////////////////////////////////////////////////////////////////////////////////////////////////

$rs = $db->Execute("SELECT DISTINCT ID, NAME FROM PEOPLE WHERE
UPPER(NAME_DISPLAY) LIKE '".$_GET['searchCriteria']."%'");

$results = null;
while ($arr = $rs->FetchRow()) {
echo "obj.options[obj.options.length] = new
Option('".rawurlencode($arr["NAME"])."','".rawurlencode($arr["ID"])."');
\n";
}

exit;
}

?>

<link href="style.css" rel="stylesheet" type="text/css" />

<!-- AJAX for processing customer name search -->
<script type="text/javascript" src="ajax.js"></script>
<script type="text/javascript">

var ajax = new sack();

function searchInput(input)
{
//Set a variable to hold the value from the form input field
var searchCriteria = input.value;

//Empty results select box
document.getElementById('result').options.length = 0;

//If there is search criteria, then process
if(searchCriteria.length>0)
{
//Pass to php to process
ajax.requestFile = 'tst2.php?searchCriteria='+searchCriteria;

//Specify function that will be executed to display results
ajax.onCompletion = createResults;

//Execute AJAX function
ajax.runAJAX();
}
}

function createResults()
{
var obj = document.getElementById('result');

//Executing the response from Ajax as Javascript code
//Sent from php as an escaped string so must escape
alert(unescape(ajax.response));
eval(unescape(ajax.response));
}

</script>
<!-- END AJAX for processing customer name search -->


<table>
<tr>
<td><b>Customer Name:</b></td>
<td>
<input class="cust" id="search" name="search" type="text"
onchange="searchInput(this)">
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><select multiple size="10" id="result" name="result">

</select>
</td>
</tr>
</table>
 
J

Jeff North

| Ok, Here is the code for what I am doing, and the ajax library being
| used is SACK from http://twilightuniverse.com/projects/sack/ I just
| can't seem to pass more than about 6100 characters... Any ideas, or a
| better way to go?

I recommend POSTing your form that way there is virtually no limit on
the input size.
| <?php
|
| //If some search criteria was sent
| if(isset($_GET['searchCriteria']))
| {
|
| //////////////////////////////// DB
| Connection ///////////////////////////////////////////////////////
| //////////////////////////////////////////////////////////////////////////////////////////////////////
|
| include('./adodb/adodb.inc.php');
|
| //Type of connection
| $db = NewADOConnection('oci8');
|
| //Sets the query results to come back as assoc arrays
| $db->SetFetchMode(ADODB_FETCH_ASSOC);
|
| //Make the connection
| $db->PConnect('xxxxx', 'yyyyy', 'zzzzz');
|
|
|
| //////////////////////////////////////////////////////////////////////////////////////////////////////
|
| $rs = $db->Execute("SELECT DISTINCT ID, NAME FROM PEOPLE WHERE
| UPPER(NAME_DISPLAY) LIKE '".$_GET['searchCriteria']."%'");
|
| $results = null;
| while ($arr = $rs->FetchRow()) {
| echo "obj.options[obj.options.length] = new
| Option('".rawurlencode($arr["NAME"])."','".rawurlencode($arr["ID"])."');
| \n";
| }
|
| exit;
| }
|
| ?>
|
| <link href="style.css" rel="stylesheet" type="text/css" />
|
| <!-- AJAX for processing customer name search -->
| <script type="text/javascript" src="ajax.js"></script>
| <script type="text/javascript">
|
| var ajax = new sack();
|
| function searchInput(input)
| {
| //Set a variable to hold the value from the form input field
| var searchCriteria = input.value;
|
| //Empty results select box
| document.getElementById('result').options.length = 0;
|
| //If there is search criteria, then process
| if(searchCriteria.length>0)
| {
| //Pass to php to process
| ajax.requestFile = 'tst2.php?searchCriteria='+searchCriteria;
|
| //Specify function that will be executed to display results
| ajax.onCompletion = createResults;
|
| //Execute AJAX function
| ajax.runAJAX();
| }
| }
|
| function createResults()
| {
| var obj = document.getElementById('result');
|
| //Executing the response from Ajax as Javascript code
| //Sent from php as an escaped string so must escape
| alert(unescape(ajax.response));
| eval(unescape(ajax.response));
| }
|
| </script>
| <!-- END AJAX for processing customer name search -->
|
|
| <table>
| <tr>
| <td><b>Customer Name:</b></td>
| <td>
| <input class="cust" id="search" name="search" type="text"
| onchange="searchInput(this)">
| </td>
| </tr>
| <tr>
| <td>&nbsp;</td>
| <td><select multiple size="10" id="result" name="result">
|
| </select>
| </td>
| </tr>
| </table>
 
S

Satya

| Ok, Here is the code for what I am doing, and the ajax library being
| used is SACK fromhttp://twilightuniverse.com/projects/sack/I just
| can't seem to pass more than about 6100 characters... Any ideas, or a
| better way to go?

I recommend POSTing your form that way there is virtually no limit on
the input size.


| <?php
|
| //If some search criteria was sent
| if(isset($_GET['searchCriteria']))
| {
|
| //////////////////////////////// DB
| Connection ///////////////////////////////////////////////////////
| //////////////////////////////////////////////////////////////////////////////////////////////////////
|
| include('./adodb/adodb.inc.php');
|
| //Type of connection
| $db = NewADOConnection('oci8');
|
| //Sets the query results to come back as assoc arrays
| $db->SetFetchMode(ADODB_FETCH_ASSOC);
|
| //Make the connection
| $db->PConnect('xxxxx', 'yyyyy', 'zzzzz');
|
|
|
| //////////////////////////////////////////////////////////////////////////////////////////////////////
|
| $rs = $db->Execute("SELECT DISTINCT ID, NAME FROM PEOPLE WHERE
| UPPER(NAME_DISPLAY) LIKE '".$_GET['searchCriteria']."%'");
|
| $results = null;
| while ($arr = $rs->FetchRow()) {
| echo "obj.options[obj.options.length] = new
| Option('".rawurlencode($arr["NAME"])."','".rawurlencode($arr["ID"])."');
| \n";
| }
|
| exit;
| }
|
| ?>
|
| <link href="style.css" rel="stylesheet" type="text/css" />
|
| <!-- AJAX for processing customer name search -->
| <script type="text/javascript" src="ajax.js"></script>
| <script type="text/javascript">
|
| var ajax = new sack();
|
| function searchInput(input)
| {
| //Set a variable to hold the value from the form input field
| var searchCriteria = input.value;
|
| //Empty results select box
| document.getElementById('result').options.length = 0;
|
| //If there is search criteria, then process
| if(searchCriteria.length>0)
| {
| //Pass to php to process
| ajax.requestFile = 'tst2.php?searchCriteria='+searchCriteria;
|
| //Specify function that will be executed to display results
| ajax.onCompletion = createResults;
|
| //Execute AJAX function
| ajax.runAJAX();
| }
| }
|
| function createResults()
| {
| var obj = document.getElementById('result');
|
| //Executing the response from Ajax as Javascript code
| //Sent from php as an escaped string so must escape
| alert(unescape(ajax.response));
| eval(unescape(ajax.response));
| }
|
| </script>
| <!-- END AJAX for processing customer name search -->
|
|
| <table>
| <tr>
| <td><b>Customer Name:</b></td>
| <td>
| <input class="cust" id="search" name="search" type="text"
| onchange="searchInput(this)">
| </td>
| </tr>
| <tr>
| <td>&nbsp;</td>
| <td><select multiple size="10" id="result" name="result">
|
| </select>
| </td>
| </tr>
| </table>

Yes do Post-ing with <?php ob_start('ob_gzhandler');?> in your PHP
file. This will compress your data.
 
M

Manuel Lemos

Hello,

I am using ajax / php where I am looking up some info from the
database and populating a select list dynamically, however I am
running into some sort of size limitation with the ajax.response
object. If the string I am passing to javascript from php is too large
javascript does not get it all the data. The magic number appears to
be 6123 characters, anything below that it works fine, anything above
and if I alert the ajax.response, I see the string is cutoff. Any
ideas where this limitation is defined?

You may want to take a look at this class that comes with a plug-in
named linked select that links 2 or more select inputs populating each
select input using option values retrieved from a database with AJAX.

http://www.phpclasses.org/formsgeneration

Here is the live example script that demonstrates what you want:

http://www.meta-language.net/forms-examples.html?example=test_linked_select

Here you can see a video of the part of this class tutorial that
explains the linked select input plug-in:

http://www.phpclasses.org/browse/video/1/package/1/section/plugin-linked-select.html


--

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top