Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Collection.prototype.storeOfflineData = function(collectionId){
- var formData = new FormData($('form')[0]);
- pendingSites = {"collectionId" : collectionId, "formData" : formData};
- window.localStorage.setItem("offlineSites", JSON.stringify(pendingSites));
- Collection.prototype.goHome();
- Collection.prototype.showErrorMessage("Successfully store data in offline.");
- }
- Collection.prototype.pushingPendingSites = function(){
- pendingSites = JSON.parse(window.localStorage.getItem("offlineSites"));
- if(pendingSites != null){
- console.log(pendingSites[i]["formData"]);
- Collection.prototype.ajaxCreateSite(pendingSites[i]["collectionId"], pendingSites[i]["formData"]);
- }
- }
- Collection.prototype.ajaxCreateSite = function(collectionId, formData){
- $.ajax({
- url: '/mobile/collections/' + collectionId + '/sites', //Server script to process data
- type: 'POST',
- success: function(){
- Collection.prototype.goHome();
- Collection.prototype.showErrorMessage("Successfully saved.");
- },
- error: function(data){
- Collection.prototype.showErrorMessage("Save new site failed!");
- },
- data: formData,
- cache: false,
- contentType: false,
- processData: false
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement