A Brief Description...
I have an editable jqWidgets grid within my site but unlike traditional editable grids, instead of updating the database as you edit a row, I want to update the entire grid at once when a 'Save' button is pressed.
With this in mind, I can only see two possible options:
- Somehow stringify the entire grid object into a query string and send 1 AJAX request to the server.
- Or, loop through each row and execute an AJAX request for each individual row in the grid
The issue I have is that I simply cannot figure out which method is better as they both have their complications. The query string on option 1 could potentially be astronomical and exceed memory limits as the user is trying to pass the entire contents of the grid over a POST request. However, the latter solution could cause issues by the fact that it is executing an AJAX request for each row in the grid. Imagine if there were 100, or even 1000 rows in the grid!!
My Question
So, can anybody think of an effective way to achieve this without exceeding memory limits, but whilst also avoiding making multiple AJAX requests?
Further Information
In case the above wasn't clear, consider this javascript array:
[
{ name: 'Ben', age: 23, occupation: 'Developer' },
{ name: 'Charlie', age: 24, occupation: 'Receptionist' },
{ name: 'Jemima', age: 18, occupation: 'Designer' }
]
And now, try to ascertain the best method for passing all that information to PHP in one query?