2016-01-19 17 views
1

我想在ajax调用返回成功后在fancybox内呈现gsp页面。ajax成功后呈现gsp页面

我也做了以下内容:

function editCompanyProfile(companyProfileId){ 
    $.ajax({ 
     url: '${createLink(controller: 'benefitContract',action: 'editCompanyProfile')}', 
     type: 'POST', 
     data: {id:companyProfileId}, 
     success: function (data) { 
      $.fancybox({ 
      /* I need to render a gsp here */ 
      }) 
     } 
    }) 

}

 def editCompanyProfile(){ 
      def isroleAdministrator=false 
    if (User.findById(session.userId).allAuthorities?.contains('ROLE_ADMINISTRATOR')){ 
     isroleAdministrator=true; 
    } 
    render(template:"/benefitContract/companyProfile",model:[isroleAdministrator:isroleAdministrator,companyProfile:params.id]) 
} 

谁能告诉我,我应该怎么去这样做呢?

回答

0

为什么不尝试覆盖div的内容。它将不那么单调乏味,更加完美无暇。

function editCompanyProfile(companyProfileId,groupId){ 
    $.ajax({ 
     url: '${createLink(controller: 'benefitContract',action: 'addEditCompanyProfile')}', 
     type: 'POST', 
     data: {sourceId:companyProfileId,groupId:groupId}, 
     success: function (data) { 
      $('#companyProfile').html(data); 
     } 
    }) 
} 
+1

...我试着按照你的说法,它给了我想要的结果。你是对的,而不是打开一个新的花哨盒重写div的内容是更有效率.. –