Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 在gsp中解析json并更新内容_Jquery_Json_Grails - Fatal编程技术网

Jquery 在gsp中解析json并更新内容

Jquery 在gsp中解析json并更新内容,jquery,json,grails,Jquery,Json,Grails,我在grails控制器中有这样一个方法,我在gsp的jquery中调用它 def ajaxStatus(){ CustomerInterest customerInterestInstance=CustomerInterest.get(params.ciId) InterestStatus status=InterestStatus.valueOf(params.status) customerInterestInstance.status=status

我在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>

如果您想更新div,那么可以使用jQuery的html。如果你想更新${ci?.status},那么把它放在一个span中,给这个span一个id,然后使用html。我知道这一点,但在使用html之前,我必须解析json。。。?正确与否?您在ajax中的响应变量中获得了json响应。在那里,您可以轻松获得customerInterestInstance的任何属性,如response.Status非常感谢@user1690588
  "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');
                }
              },