开发者

PHP / jQuery / AJAX form update best practices

On one of my pages I pull a table of data from the database and display it to the user, giving them the option to update the values for each row. My question is what is the best way to do this?

Currently, i'm stuck between two options. Option one is to display one form with all of the inputs. My other idea was to have each row be a form itself. Is there an advantage 开发者_如何学编程to one over the other? Right now i'm leaning towards the the latter of the two - as it seems like much less overhead to only POST data for one row as opposed to all of them for a single update.


You should certainly define separate forms for every row. No need to send all the data all the time.

Semantically, they are also separate forms. It is also easier to handle the data you get on the server side.


you could set it up so that when a record is clicked the data for that record(id,name,other...) are loaded into a form in a jQuery ui dialog then have two buttons on the dialog (save,cancel)

Save: use ajax to send the data to a php data helper which will update the record in the database

cancel: clear the fields in the form and close the dialog

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜