$(document).on("click", "buyCrypto", function() {
var buyCryptoButton = document.getElementById("buyCrypto");
buyCryptoButton.disabled = true;
var data='id=userId&csrfToken=csrfToken';
url:"WidgetInitialiseScript.php",
if (url == "checks failed") {
var win = window.open(url , "myWin", "toolbar=no, directories=no, location=no, status=yes, menubar=no, resizable=no, scrollbars=yes, width=515, height=600");
// sets interval timer to see if the utility window is open.
// If it is open the interval timer continues
// if the window has been closed, enable the button to start a new widget,
var interval = window.setInterval(function() {
if (win == null || win.closed) {
window.clearInterval(interval);
buyCryptoButton.disabled = false;
error: function(jqXHR, textStatus, errorThrown) {
alert("Error type" + textStatus + "occured with value " + errorThrown);