在gsp中解析json并更新内容

时间:2014-06-12 07:47:58

标签: jquery json grails

我在grails控制器中有一个方法,我在gsp中用jquery调用....

def ajaxStatus(){

     CustomerInterest customerInterestInstance=CustomerInterest.get(params.ciId)

     InterestStatus status=InterestStatus.valueOf(params.status)
     customerInterestInstance.status=status

     customerInterestInstance.save(flush:true,failOnError:true)

     render customerInterestInstance as JSON
 }

问题

  

我想解析gsp中的customerInterestInstance并更新gsp中的内容我该怎么办?   此

我要更新的代码是.....

 <span class="staFloat">  
     ${ci?.status}         
         <button onclick="openDialog(${ci?.id})"class=btn id="btn">
            <img id="status_edit"src="${resource(dir:'images/skin',file:'edit.png')}"/>
        </button>
</span>

jquery函数

  "Change": function(){

                  var st = $('[name="st"]:checked').val();


                  $.ajax({
                     url: "${createLink(controller: 'Employee', action: 'ajaxStatus')}",
                      data: ({
                        ciId:ciId,
                        status:st
                          }), 
                      dataType:"JSON",

                success: function(response) { 

                         // call 'refresh' method to load new content

                    alert("changed")  
                       },
               error: function(){
                      alert("Select options");  
                   }

                    });           
                  $(this).dialog('close');
                },
              Cancel : function() {
                    $(this).dialog('close');
                }
              },

0 个答案:

没有答案