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);  
                    })
//                     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","*");
        
//        response.setCharacterEncoding("UTF-8");
//        Writer out = response.getWriter();
//        System.out.println("dsds");
//        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) + ")");
        // renderJson("callback(" + JsonKit.toJson(list) + ")");
        renderJson(String.format("%s(%s)",callback,JsonKit.toJson(list)));
    }
原文链接:/json/729973.html

猜你在找的Json相关文章