Skip to content

Instantly share code, notes, and snippets.

@gseilheimer
Last active October 5, 2015 15:10
Show Gist options
  • Save gseilheimer/51abc115aab75da73c66 to your computer and use it in GitHub Desktop.
Save gseilheimer/51abc115aab75da73c66 to your computer and use it in GitHub Desktop.
snippet js localstorage ajax
// LocalStorage
function saveRating() {
localStorage.clear();
if( window.localStorage!==undefined ) {
var fields = $( "form :input" ).serialize();
localStorage.setItem( "form-rating-fields", JSON.stringify( fields ) );
console.log( fields );
alert( "Stored Succesfully" );
//$( "form :input" ).find( "input[type=radio]" ).val( "" );
//alert("Now Passing stored data to Server through AJAX jQuery");
$.ajax({
type: "POST",
url: "index_saverating.php",
data: fields,
success: function(data) {
console.log(data);
//$('#output').html(data);
}
});
} else {
alert( "Storage Failed. Try refreshing" );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment