Widgets Dialog : JQUERY UI LOAD CONTENT FROM URL (Javascript is not invoked in popup model)

Widgets Dialog : JQUERY UI LOAD CONTENT FROM URL (Javascript is not invoked in popup model)

Hello,

I was able to load the external URL JSP page content into Div of parent page but Javascript functionality in popup is not working for any buttons. 
Below is the code to open popup and load the content .

(function($){
var url = "Servlet path";
var tag = $("<div></div>");
tag.dialog({ 
   autoOpen: false,
   height: 230,
   width: 550,
   modal: true,
   beforeClose: function(event, ui)
   {
   alert("beforeClose called");
   }
});
$.ajax({ 
  type: "GET", 
  url: "Servlet path",
  dataType: "html", 
  data: "1,1,1,1",
  success: function(data) {   
   document.getElementById("targetDiv").innerHTML = data;
  }, 
  error: function(obj, statusCode,errorDesc){ 
  alert("Error", obj); 
  alert("Error", statusCode); 
  alert("Error", errorDesc); 
  } 
  });
})(jQuery);

Kindly advice any approach, any suggestions , any sample code or existing examples.