Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>All info necessary to save/restore user efforts is in your states[] array which contains javascript objects defining the status of all your drag-drop items.</p> <p>Actually...</p> <p>...There's a LOT of info about serializing, transporting, saving, retrieving and deserializing javascript objects ;)</p> <p>For serializing javascript objects, use <code>JSON.stringify</code> which can serialize your array of objects into a single JSON string (JSON stands for JavaScriptObjectNotation). This single string is easily transported to your server for posting to your database.</p> <p>To get your state information back, you can ask the server to give you that same JSON string back. You can turn that JSON string back into an array of objects using <code>JSON.parse</code>.</p> <p>To transport and receive your JSON data string, you can use jQueries <code>$.ajax</code> method. Ajax can be used to send info to your server--this is called an ajax POST. Ajax can be used to request info from your server--this is called an ajax GET.</p> <p>When your server gets a POST request, it will take the JSON string you supply and save it in a database.</p> <p>When your server gets a GET request, it will query the database to retrieve the saved JSON string and send it back to your user.</p> <p>Setting up a server and a database is beyond the scope of a stackoverflow question, but here is a nice series of tutorials on how jQuery, JSON, Ajax, Php and MySQL-database can be used together to save and restore state:</p> <p>www.youtube.com/watch?v=Yz0RF__mFDU</p> <p>Here is a quick example of client-side code to serialize and POST your state information:</p> <pre><code>// Serialize the states array var JsonStringForTransport = JSON.stringify({stateForUserNumber7: states}); // POST the JSON to your server var thePost = $.ajax({ url: 'saveToServer.php', type: 'POST', dataType: 'json', data: JsonStringForTransport, contentType: 'application/json; charset=utf-8' }); thePost.always(function(result){ // use this during testing to be sure something's happening }); thePost.fail(function(result){ // handle failure }); thePost.done(function(result){ // handle success }); </code></pre> <p>Good luck in your project! :)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload