Open window with information (AJAX WAY)

In this example we will execute AJAX that will return data which will be visualised in new window (tab).

$(document).on("click", ".sysnav", function(){ //On clicked button
	id=$(this).attr('id');                 //Command that will be executed in script.php
		$.ajax({
			  url:'script.php',
			  type:'POST',
			  data:{ 
				command:id 
			  }  
		}).done(function(data){
			var target = window.open("/admin.php");   //Open new window
			target.NavigationPopup = data;	          //Data to be loaded in new window
		});		
});

Div with class “content” in new window will be filled with data from AJAX.
File “admin.php”(new window) must include this code.

var NavigationPopup;            //Data from ajax

$(document).ready(function(){
	if(NavigationPopup){ 	$('.content').html(NavigationPopup);	} //Fill the "content" div
}

Leave a Reply

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