Question

I make an AJAX call to a server and retrieve occasionally a warning msg I need to show to the user. I tried alert and it works but it looks bad as the text is long and unformatted.
Googling I found that JQuery has a Dialog widget that suits me but I can not figure out how to pass the content string to display. I see that I can pass a text to be the dialog's title but if in ajax call I have a var result_msg how can I open the dialog to show in the main body the text of result_msg?

Was it helpful?

Solution

You can do this in your success function of ajax:

$( "#dialog-message" ).html(respTxt).dialog({
    modal: true,
    buttons: {
      Ok: function() {
        $( this ).dialog( "close" );
      }
    }
}).css('height', 200);// <-----------------------add this and below one
$('.ui-widget-overlay').css('height', 'auto');

Fiddle for help.
Updated Fiddle

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top