开发者

Jquery ajax with multiple modal windows

I am using a Struts application with JQuery as Javascript library. I have a JSP with a button that invokes a Javascript method that fires an AJAX request to an Action. (Action 1)

The Action returns a JSP page that is displayed within a modal window.

Now, this JSP page has a button that invokes another action (Action 2) that returns a JSP page or should return to the base page.

So the case here is of a modal window click leading to eithe开发者_C百科r another modal window or to the base page.

How do we best accomplish this with JQuery ?


you could return either the string "close" or the html for the new modal window and do something along this line:

   $.ajax({ url: 'someUrl',
      success: function(data){
         if(data.toLowerCase().indexOf('<html') == -1)
            $('#modalwindow1').dialog('close');
         else
         {
            $('#modalwindow2').html(data);
            $('#modalwindow2').dialog();
         }
      }
   });

This assumes you are using JQuery.dialog for your modal windows

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜