jsonp 跨域

前端之家收集整理的这篇文章主要介绍了jsonp 跨域前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
            $.ajax({ 
                url:"http://192.168.100.47:8080/ais-connect/data/newaisSyn",type:‘GET‘,dataType:‘JSONP‘,jsonp: ‘callback‘,success: function(data){ 
                var myshipids=data;
                    console.log(data);
                    $.each(data,function(i,obj){
                          console.log(obj.MMSI);  
                    })
@H_404_20@//@H_404_20@                     console.log(123);
                },error: function(jqXHR,textStatus,errorThrown ){
                      console.log(textStatus);
                      console.log(errorThrown);
                }
            }); 






public  void newaisSyn() throws IOException{
        
        HttpServletRequest request = getRequest();
        
        HttpServletResponse response = getResponse();
        response.setHeader("Access-Control-Allow-Origin","*");
        
@H_404_20@//@H_404_20@        response.setCharacterEncoding("UTF-8");
@H_404_20@//@H_404_20@        Writer out = response.getWriter();
@H_404_20@//@H_404_20@        System.out.println("dsds");
@H_404_20@//@H_404_20@        out.write("dsds");
        List<Record> list = Db.use("ais").find("SELECT  d.mmsi FROM T_SHIP_TRACK_RECENT d where rownum<=10");

        String callback = request.getParameter("callback");
        
        System.out.println("callback(" + JsonKit.toJson(list) + ")");
        @H_404_20@//@H_404_20@ renderJson("callback(" + JsonKit.toJson(list) + ")");
        renderJson(String.format("%s(%s)",callback,JsonKit.toJson(list)));
    }

猜你在找的Json相关文章