使用Laravel在DB中输入数据的Jquery / Ajax或PHP会话

使用Laravel在DB中输入数据的Jquery / Ajax或PHP会话

问题描述:

I would like to get an idea of what a "Best Practice" may be. I am redeveloping a web app I made, that allows users to select items from a dropdown list, add them to a "Queue" and then allows the user to save them to the DB as their user when the info is finished being entered.

Currently, I am using, Jquery/Ajax to get the data from the selections, add it an array, then append it to the Queue Table.

When the user clicks save, it passes the array through ajax to PHP to send it to the database.

I am recreating this application in laravel, and wonder if it would be better to store the user defined data into a session and then pass it directly to the php script to insert it into a database.

I am not familiar as familiar as I would like to be with sessions, so I would like your advice if this is worth pursuing or if I would be using sessions wrong.

我想知道“最佳实践”可能是什么。 我正在重新开发我制作的网络应用程序,允许用户从下拉列表中选择项目,将它们添加到“队列”,然后允许用户在输入信息时将其作为用户保存到数据库中。 p>

目前,我正在使用Jquery / Ajax从选择中获取数据,添加一个数组,然后将其附加到队列表。 p> 当用户单击save时,它会通过ajax将数组传递给PHP,以将其发送到数据库。 p>

我在laravel中重新创建这个应用程序,并想知道将用户定义的数据存储到会话中然后将其直接传递给php脚本以将其插入数据库是否更好 。 p>

我对熟悉的课程并不熟悉,所以如果值得追求,或者我会错误地使用会话,我希望得到你的建议。 p> div>

Your PHP script that will receive the Ajax data is an API. The user needs to be previously authenticated via a session or token, but when the Ajax call is made, you need to parse the data received and immediately pass it to your database storage routines.