简体   繁体   English

动态创建的html元素保存到数据库?

[英]Dynamically Created html elements saved to database?

I have been teaching myself javascript and now wish to take my program live so I can develop further to learn more and more. 我一直在教自己javascript,现在希望我的课程现场,所以我可以进一步发展,学习越来越多。

What I am looking to do is store all the rows/cells that are created by the user into a database. 我要做的是将用户创建的所有行/单元存储到数据库中。 So that when they reload the page or someone else loads the page. 这样当他们重新加载页面或其他人加载页面时。 They can see all the information that other people have added. 他们可以看到其他人添加的所有信息。

Now I feel the best way to do this was to have it sent to the database upon the user clicking a 'save to database' button. 现在我觉得这样做的最好方法是在用户点击“保存到数据库”按钮后将其发送到数据库。

What is the best way to do this, and how would I go about it? 这样做的最佳方法是什么,我将如何解决这个问题?

Here is my code: 这是我的代码:

https://github.com/harryth3hopp3r/JobList https://github.com/harryth3hopp3r/JobList

Any help would be appreciated! 任何帮助,将不胜感激!

If you want to share data between users you should build a backend for it. 如果要在用户之间共享数据,则应为其构建后端。 Then you can send the data to the backend with an AJAX call, for example. 然后,您可以使用AJAX调用将数据发送到后端。

If you are to build a backend you would need a web server to make it available to your users. 如果要构建后端,则需要Web服务器才能使其可供用户使用。

If you want to stick with Javascript you could use NodeJS in your server infrastructure, and then you can connect it to a mongoDB database, which is quite simple to use. 如果你想坚持使用Javascript,你可以在你的服务器基础设施中使用NodeJS,然后你可以将它连接到一个非常简单易用的mongoDB数据库。 I could explain the whole process but I think it's better that you go through the specific tutorials and make more specific questions when they come. 我可以解释整个过程,但我认为最好通过具体的教程,并在它们到来时提出更具体的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM