简体   繁体   中英

Saving dynamically created content to server & load from there

So I have this webpage that I'm making which allows people to create elements on the page on the fly. And I want to be able to save those elements to my server and whenever someone else reloads that page, the webpage will have those saved elements.

I'm not a good web programmer by any means, so take it easy with the web jargon xD

The user created elements are nested 's or lists. Those elements can be deleted at anytime as well.

So I was reading about saving them as JSON but how would I go about doing that as my 's, most of the top level ones will have the same class. Never worked with JSON before, so I'm a real noob at that.

Will the server file keep replacing itself with a brand new copy with each addition/deletion?

And I'd like to get a little help with showing the new elements without updating. On other users page. I read about AJAX real-time updating, like APE, but have no idea how to go about with that. (This is not really needed but would be a nice one to have)

If someone can guide me a little at least, that will be great. Thanks.

The best suitable way to accomplish this is by saving your objects attributes to a database, however other options include XML files etc..

The process of accomplishing it through database is:

  • If you want to save data to database then you will have to use a server side language like Php or Asp.net, so first step will be to have a database then an active connection to your database on your intermediate file (lets say 'data.php')

  • Then you need to code your data.php file so that it can take input(usually through GET or POST method) and it can save it to your database

  • Then you need to pass your data (objects attributes) through AJAX to data.php and save them to your database

  • On the main file you will have to check whether already some data exists for user, if yes then fetch it from database and display objects accordingly, otherwise set the objects preferences to default

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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