Created
April 18, 2012 10:23
-
-
Save Crystalh/2412673 to your computer and use it in GitHub Desktop.
JSON loader replacement
This file contains hidden or 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
function Jsonloader(options) { | |
var defaults = { | |
callbackInterval: 15000 //15 seconds | |
callbackString: "jsoncallback", | |
success = options.success || function() { }, | |
url = options.url || "" | |
}; | |
this.defaults = jQuery.extend(true, defaults, options || {}) | |
} | |
//PUBLIC API METHODS AND PROPERTIES | |
Jsonloader.prototype.loadJson = function() { | |
var that = this; | |
return $.ajax({ | |
url : this.url, | |
dataType : 'jsonp', | |
jsonpCallbackString : this.callbackString, | |
success : function(data) { that.success(data) } | |
}); | |
} | |
Jsonloader.prototype.setCallbackInterval = function() { | |
//set callbackInterval prop on Jsonloader object | |
} | |
Jsonloader.prototype.createUpdateTimer = function() { | |
//create setTimeout, which calls loadJson() method | |
} | |
Jsonloader.prototype.stopPolling = function() { | |
//clear timeout | |
} | |
Jsonloader.prototype.startPolling = function() { | |
//call createUpdateTimer() | |
} | |
//PRIVATE METHODS AND PROPERTIES | |
function clearTimer(timer) { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment