Last active
October 5, 2015 15:10
-
-
Save gseilheimer/51abc115aab75da73c66 to your computer and use it in GitHub Desktop.
snippet js localstorage ajax
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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