2016-10-12 02:15
浏览 40

使用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.

图片转代码服务由CSDN问答提供 功能建议

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

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

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


  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dou44364983 2016-10-12 02:20

    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.

    解决 无用
    打赏 举报

相关推荐 更多相似问题