Skip to content

Instantly share code, notes, and snippets.

@MeoMix
Created November 3, 2012 20:52
Show Gist options
  • Save MeoMix/4008710 to your computer and use it in GitHub Desktop.
Save MeoMix/4008710 to your computer and use it in GitHub Desktop.
//Cross-Origin Resource Sharing unavailable from file://
if(window.location.protocol !== 'file:'){
if(window.location.protocol === 'chrome-extension:') {
$.ajax({
url: 'http://www.geoplugin.net/json.gp',
success: function(result) {
var geoplugin = JSON.parse(result.replace(/^[^\{]+/, '').replace(/\);?$/, ''));
countryCode = geoplugin.geoplugin_countryCode;
}
});
}else {
$.ajax({
url: 'http://www.geoplugin.net/json.gp',
dataType: 'jsonp',
jsonp: 'jsoncallback',
success: function(result) {
countryCode = result.geoplugin_countryCode;
window.countryCode = countryCode;
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment