Skip to content Skip to sidebar Skip to footer

How To Open Jquery Ui Dialog With Ajax Request?

On my web page I have a jQuery UI Dialog. When I click the button (create new user) it opens a new window. My question is how can I open that window with an AJAX request? It would

Solution 1:

You can define your dialog like this :

functionshowUrlInDialog(url){
  $.ajax({
    url: 'dialog.html',
    success: function(data) {
      $("#dialog-form").load(data).dialog({modal:true}).dialog('open');
    }
  });
}    

And define the current markup that is inside dialog-form div, into a new page called dialog.html. Call the above written function on the button click event. I hope this is what you needed.

Solution 2:

I think this is a simpler version of the answer:

$("#the-button").click(function(){
  $("#dialog").dialog({modal: true}).dialog('open')).load("dialog.html")
})

Solution 3:

For me .load is not working. So I used,

functionshowUrlInDialog(url){
  $.ajax({
    url: 'dialog.html',
    success: function(data) {
      $("#dialog-form").html(data).dialog({modal:true}).dialog('open');
    }
  });
} 

Post a Comment for "How To Open Jquery Ui Dialog With Ajax Request?"