Skip to content

Instantly share code, notes, and snippets.

@ddo
Created January 31, 2013 09:35
Show Gist options
  • Save ddo/4681676 to your computer and use it in GitHub Desktop.
Save ddo/4681676 to your computer and use it in GitHub Desktop.
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