Solution 1 :

This should work:

var tab = window.open('about:blank', '_blank');
tab.document.write(data); 
tab.document.close();

Source: https://stackoverflow.com/a/49019549/12968095

Problem :

I have an ajaxcall which returns an html page to me in the response. I want to open this in a new window. How to make this work?

Image

console.log(data) basically prints the entire html content as if it were a single string

Comments

Comment posted by mplungjan

Why Ajax?? If you want to open a page in a new window, use a link to the source of the HTML and

Comment posted by anwesh mohapatra

Unfortunately I can only share an api. How do I trigger javascript on client side then?

Comment posted by mplungjan

If you can do console.log you can do what is suggested in the answer too

Comment posted by anwesh mohapatra

I can only give them the rest api. How can I call the javascript you wrote in that situation?

By

Leave a Reply

Your email address will not be published. Required fields are marked *