首页 > Web开发 > 详细

jquery ajax/post 请求 案例

时间:2017-04-21 19:00:39      阅读:291      评论:0      收藏:0      [点我收藏+]

@RequestMapping("/hello")
    @ResponseBody
    public Hello getJson(HttpServletRequest request,HttpServletResponse response,Model model){
            Hello hello=new Hello();
            hello.setStr("hello world");
        return hello;
    }

 

<span id="hello">hello</span>

 

//post请求

$("#hello").click(function(){
    $.post("${ctx}/partner/hello",function(data){alert(data.str);},"json");
});

 

//ajax请求

$("#hello").click(function(){
    $.ajax({
         type: "POST",
         url: "${ctx}/partner/hello",
         dataType:"json",
         success: function(data){
           alert( "data: " + data.str );
         }
    });
});

jquery ajax/post 请求 案例

原文:http://www.cnblogs.com/austinspark-jessylu/p/6744926.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!