CURRENT PROJECTS
loading
(function($) {
// configure this to the globally available object you would like to autosave
$.autoSave.object = _cart;
// load checking function on interval to autosave via AJAX
$(document).ready( function () {
// the jquery.json.js plugin must be included
if ( typeof($.toJSON) != 'function' ) return false;
// setup the interval function - ensure only once.
$.autoSave.intervalId = $.autoSave.intervalId || window.setInterval(function () {
// only if the object has changed value in any way - this is a semi-expensive operation
if ( $.toJSON($.autoSave.object) != $.autoSave._oldObjString )
// formulate a simple POST with the JSON serialized data to save in the session
$.ajax({data: 'saveObject=' + $.toJSON($.autoSave.object),
type: 'POST',
success: function () { $.autoSave._oldObjString = $.toJSON($.autoSave.object); },
url: 'saveHandler.php'});
}, 900);
} );
})(jQuery);
<?php session_start(); if ( $_REQUEST['saveObject'] ) $_SESSION['saveObject'] = $_POST['saveObject']; ?>
<!--- ensure clientManagement="Yes" is set in Application.cfc --->
<!--- if new object, save in the CLIENT variables (albeit limited in length) --->
<cfif IsDefind('FORM.saveObject') and Len(FORM.saveObject) gt 0>
<cfset CLIENT.saveObject = FORM.saveObject>
</cfif>

