Opening the result of GET request with data in a new tab - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:ajax

Description

Opening the result of GET request with data in a new tab

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js"></script> 
  <script type="text/javascript">
    window.onload=function(){//ww w  .java  2 s  .c om
var root = 'https://jsonplaceholder.typicode.com';
$.ajax({
  url: root + '/posts/1',
  method: 'GET'
}).then(function(data) {
  var newWindow = window.open();
  newWindow.document.write(data.title);
});
    }

      </script> 
 </head> 
 <body>  
 </body>
</html>

Related Tutorials