Reputation: 361
I have ajax request:
function sendData(user) {
$.ajax({
type: 'POST',
url: '/user-check',
data: JSON.stringify(user),
headers: {
'Accept': 'application/text',
'Content-Type': 'application/json',
},
dataType: 'text',
success : function(completeHtmlPage) {
alert("Success");
var pageName = completeHtmlPage + ".html";
window.open(pageName);
},
error: function() {
alert('Error authorization');
}
});
}
I want to open new page with name completeHtmlPage + ".html". How to open new page instead current page?
Upvotes: 1
Views: 2291
Reputation: 1834
Since you want to do a redirection on the same page, you could change your success
block to:
success : function(completeHtmlPage) {
alert("Success");
var pageName = completeHtmlPage + ".html";
document.location.href = pageName;
},
Upvotes: 1