I have a code in ajax that I did not create, and I do not know how to modify it so that the link opens in a new tab.
Note: It is a button, which is activated after 5 seconds of waiting, and this is only part of the code that makes up its programming.
$.ajax({
dataType: 'json', // The type of data that you're expecting back from the server.
type: 'POST', // he HTTP method to use for the request
url: goForm.attr('action'),
data: goForm.serialize(), // Data to be sent to the server.
beforeSend: function (xhr) {
submitButton.attr("disabled", "disabled");
$('a.get-link').text('<?= __('Getting link...') ?>');
},
success: function (result, status, xhr) {
//console.log( result );
if (result.url) {
//console.log( result.message + ' - ' + result.url );
$('a.get-link').attr('href', result.url).removeClass('disabled').text('<?= __('Get Link') ?>');
//submitButton.text( 'Redirecting...' );
//goForm.replaceWith( '<button class="btn btn-default" onclick="javascript: return false;">Redirecting...</button>' );
} else {
alert(result.message);
}
},
error: function (xhr, status, error) {
alert("An error occured: " + xhr.status + " " + xhr.statusText);
},
complete: function (xhr, status) {
}
});
});