Well, the response actually returns, but the jQuery code doesn't
execute.  I've isolated the problem--I have a field in the database
that stores general instructions that can be entered by a user.  There
is a carriage return for new-lines in the text that is captured.  When
one of these entries is returned, jQuery will not parse the JSON
correctly.  For example, here is my code:

                        jQuery.getJSON( "datapages/getSummary.php" , function( 
json ) {
                                alert( "json: " + json );
                                jQuery.each( json.results , function( i , item 
) {
                                        _SUMMARY.push( item );
                                        WriteSummary( item , count );
                                        ++count;
                                });
                        });


When I request all of the summaries, I never see the alert.  When I
request only a small set of entries at a time (via the DB call using
`LIMIT x,n`), I see the alert statement when I do NOT have a response
that contains the newline character (\n I'm assuming).  As soon as the
data set response contains a newline, I no longer see the alert and
the processing stops.  Other than the obvious answer of not allow
newline characters (my end product would be pretty lame), is there
anything else I can do?

Any ideas?

Thanks,

Chad


On Aug 9, 12:33 pm, "Michael Geary" <m...@mg.to> wrote:
> There is no set limit on the size of a JSON response, any more than there is
> on an HTML or XML response. You can have very large JSON responses with no
> problem.
>
> GET vs. POST would have nothing to do with this. Those are only different in
> the way the request is sent to the server; the response format for GET and
> POST is identical.
>
> When you say "it fails", what fails? Is the server failing to generate a
> complete JSON response? Is it being generated OK but running into trouble in
> the browser? What exactly is failing and how?
>
> -Mike
>
> > From: thephatp
>
> > I'm employing the getJSON call in a site I'm working on, but
> > I'm having a problem with the response not coming through if
> > it is too large.
>
> > I've read a number of posts talking about the request string
> > being too large (forcing a user to use POST), but what about
> > the response string being too large?  Would switching to POST
> > fix this?
>
> > The data coming back could be broken down into smaller
> > portions and requested separately, but this seems like way
> > overkill for what I'm needing to do, not to mention that it's
> > a nightmare trying to get it all to return in the correct
> > order (since some later requests complete before the most recent one).
>
> > My current test is requesting about 50 objects (each with
> > about 20 fields), but it fails after about 10 (scarcely
> > populated) objects.  As an alternative, I grabbed all 50 id's
> > to the objects (in MySQL database), and then proceeded to
> > request each one individually.
> > However, since the request is asynchronous, I'm getting what
> > should be ordered results back, which isn't good.
>
> > So, I see two alternatives:
>
> > (1) Find a way to request all the data up front in a single
> > call (very preferable).
>
> > (2) Request each one individually as described above, and
> > store the values in a new javascript class, then re-order
> > afterward.  This seems like overkill, and I hope I don't have
> > to go here.
>
> > Does anyone have any suggestions for #1 above or even another
> > alternative solution?  I'm all ears (or eyes in this case).
>
> > Thanks in advance for any help you can provide!
>
> > Chad

Reply via email to