Created
January 31, 2013 09:35
-
-
Save ddo/4681676 to your computer and use it in GitHub Desktop.
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 ajax(callback, url){ | |
var is_question_mark = url.indexOf("?"); | |
var remove_cache = "?random=" + Math.random(); | |
if(is_question_mark > 0) { | |
remove_cache = "&random=" + Math.random(); | |
} | |
if ($.browser.msie && window.XDomainRequest && $.browser.version < 10) { //code for IE 10- | |
var http_request = new XDomainRequest(); | |
} else if (window.XMLHttpRequest) {//Firefox, Chrome, Opera, Safari | |
var http_request = new XMLHttpRequest(); | |
} else { | |
var http_request = new ActiveXObject("Microsoft.XMLHTTP"); | |
} | |
http_request.onload=function() | |
{ | |
callback(JSON.parse(http_request.responseText)); | |
} | |
http_request.open("GET", url + remove_cache, true); | |
http_request.send(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment