grails与ajax书写

前端之家收集整理的这篇文章主要介绍了grails与ajax书写前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

gsp中js为@H_404_1@

 $.post("modifyRight",//用../..路径不正确
{"repoName":repoName},function(data,state){
         alert("state="+state)
      alert(data.result.repoRight);
},"json");

或者@H_404_1@

$.ajax({
  url: 'modifyRight',data: { repoName: repoName },success: function(data,status,xhr) {
      var responseJson = data;
      typeAheadSource = responseJson.result.repositories;
     
  },error: function(xhr,error) {
     
  }
});

后台为:@H_404_1@

def modifyRight(){
    String repoName = params['repoName']
    render(contentType: "text/json") {
        result(repoRight:"后台测试")
    }
原文链接:https://www.f2er.com/ajax/162016.html

猜你在找的Ajax相关文章