Last active
November 11, 2015 05:18
-
-
Save adamlwgriffiths/1744d720fe1a4144f114 to your computer and use it in GitHub Desktop.
This file contains 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
var loadScript = function(url, callback) { | |
/* | |
JavaScript that will load the jQuery library on Google's CDN. | |
We recommend this code: http://snipplr.com/view/18756/loadscript/. | |
Once the jQuery library is loaded, the function passed as argument, | |
callback, will be executed. | |
*/ | |
var script = document.createElement("script"); | |
script.type = "text/javascript"; | |
if (script.readyState) { //IE | |
script.onreadystatechange = function() { | |
if (script.readyState == "loaded" || script.readyState == "complete") { | |
script.onreadystatechange = null; | |
callback(); | |
} | |
}; | |
} else { //Others | |
script.onload = function() { | |
callback(); | |
}; | |
} | |
script.src = url; | |
document.getElementsByTagName("head")[0].appendChild(script); | |
}; | |
var jqueryLoaded = function($) { | |
$.ajax( | |
'/admin/metafields.json', { | |
dataType: 'json', | |
complete: function(jqXHR, textStatus) { | |
j = jqXHR.responseJSON; | |
console.log(j); | |
} | |
}); | |
}; | |
if ((typeof jQuery === 'undefined') || (parseFloat(jQuery.fn.jquery) < 1.7)) { | |
loadScript('//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js', function(){ | |
jQuery191 = jQuery.noConflict(true); | |
jqueryLoaded(jQuery191); | |
}); | |
} else { | |
jqueryLoaded(jQuery); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment