我想重定向到一个网址,我在ajax成功后得到了回复。我的代码是
<a class="download-link" target="_blank">Download</a>
$('.download-link').on('click', function (e) {
var self = $(this);
var url = "<?php echo $block->getDownloadUrl()?>";
$.ajax({
url: url,
type: 'POST',
dataType: 'json',
showLoader: true,
data: {
type: $("#type").val(),
docName: $("#docName").val(),
},
success: function (response) {
if(response){
self.attr("href", response.url);
window.open(response.url, '_blank'); //This is not working for me
}
}
});
});