--- On Tue, 11/18/08, HELLBOY <[EMAIL PROTECTED]> wrote:

> As u told I will try it on server side.  But reason for question was
> 1. I am submitting form using AJAX.
> 2. My POST data is very huge thats y i was trying to eliminate it 
>    only on client side.

Often the PHP default limit on POST is 8 MB.  Just how big are we talking about?

The main trouble with Javascript and AJAX (and even some Flash) implementations 
is that it places a processing burden on the browser computer.  It is easy to 
imagine that the person visiting your site has as new and powerful of a 
computer as you have for developing the site.  However, this is not always the 
case.  We have a couple of iBooks at home (one G3, one G4) which we use 
routinely and these struggle with sites which are poorly designed.  For example 
a big 500-movie NetFlix list often fails to resort just because the developer 
chose to do everything in Javascript rather than have a page reload after an 
item is moved.

Connection speed is another limitation, of course, and by reducing the amount 
of data sent by POST I guess you are trying to use that efficiently.

As has been noted before, this is not a Javascript group nor an AJAX group.  
There are other groups which focus on that.  Working under the assumption that 
you need to POST only changed values, there are a couple things you could try 
on the Javascript side.

One is to let PHP generate a series of Javascript statements which have the old 
values in an array and use this same array to populate the actual form.  The 
latter can be done in PHP or with some Javascript trickery.  When the "submit" 
button is clicked, you can check the values in the form with those saved in the 
array, gather up the new values and POST them with Javascript, bypassing the 
normal submit button.

Another way would be to assume that each time a form element has focus (ie the 
user clicks on it or tabs to it) that it has been changed and is a candidate 
for POST.  There are several types of events you could put in an <input> 
element such as onChange, onFocus, onClick which might pick up the user action 
and you could run Javascript code to add the new data to the array of data to 
be sent via POST to the server.

Both of these methods get rather complex.  As already noted, you should be 
validating every input value sent from a user form to make sure that it is 
within the expected range and does not contain any nastiness like an SQL 
Injection attempt.

If your form is updating a database record, you can REPLACE all of the values 
at once or perform a SELECT, make a comparison with the POST data and use 
UPDATE to replace just the fields that are different.

It would help a lot if you gave a more clear idea of what you are trying to 
accomplish and why the POST data might be so large to discourage it from being 
sent entirely on each form submission.

James Keeline

Reply via email to