(function() { // Localize jQuery variable var jQuery; /******** Load jQuery if not present *********/ if (window.jQuery === undefined || window.jQuery.fn.jquery !== '1.9.1') { var script_tag = document.createElement('script'); script_tag.setAttribute("type","text/javascript"); script_tag.setAttribute("src", "//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"); if (script_tag.readyState) { script_tag.onreadystatechange = function () { // For old versions of IE if (this.readyState == 'complete' || this.readyState == 'loaded') { scriptLoadHandler(); } }; } else { script_tag.onload = function() { jQuery = window.jQuery; main(); }; } // Try to find the head, otherwise default to the documentElement (document.getElementsByTagName("head")[0] || document.documentElement).appendChild(script_tag); } else { // The jQuery version on the window is the one we want to use jQuery = window.jQuery; main(); } /******** Called once jQuery has loaded ******/ function scriptLoadHandler() { // Restore $ and window.jQuery to their previous values and store the // new jQuery in our local jQuery variable jQuery = window.jQuery.noConflict(true); // Call our main function main(); } /******** Our main function ********/ function main() { jQuery(document).ready(function($) { /******* Load CSS *******/ var css_link = $("", { rel: "stylesheet", type: "text/css", href: "https://register.member365.org/master/assets/css/provision.css" }); css_link.appendTo('head'); /******* Load data via ajax. *******/ /* Alternate Method var jsonp_url = "https://register.member365.org/master/api/provision/get_widget"; $.getJSON(jsonp_url, function(response) { $('#provision-widget-container').html( response.html ); }); */ var xdata = {}; $.ajax({ url: 'https://register.member365.org/master/api/provision/get_widget', type: 'POST', dataType: 'json', data: xdata, success: function(response) { $('#provision-widget-container').html( response.html ); }, error: function(XMLHttpRequest, textStatus, errorThrown){ $('#provision-widget-container').html( 'Error: Could not finish ajax request. Please try again in a minute.\nError:' + XMLHttpRequest.responseText ); } }); }); } })(); // We call our anonymous function immediately