jsonp, 返回的格式要是json 。

解决方案 »

  1.   

    比如我后台组织一个Sring 的flag,要把这个单一的返回到前台呢?
      

  2.   

    你封装成json 格式 地址栏敲 url 你看下数据结构。
    //http://www.geonames.org/postalCodeLookupJSON?postalcode=10504&country=US    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-
    transitional.dtd">
    <html>    
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
            <title>
                xxx
            </title>
            <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
            </script>
            <script type="text/javascript">
                jQuery(document).ready(function() {
                    $.ajax({
                        type: "get",
                        async: false,
                        data: {                        
                        },
                        url: "http://www.geonames.org/postalCodeLookupJSON?postalcode=10504&country=US",
                        dataType: "jsonp",
                        jsonp: "callback",
                        success: function(json) {                        
                            for (var e in json.postalcodes[0]) {                       
                                document.write(e + "--->" + json.postalcodes[0][e]+"<br/>");                            
                            }
                        },
                        error: function(XMLHttpRequest, textStatus, errorThrown) {
                            alert(XMLHttpRequest.status);
                            alert(XMLHttpRequest.readyState);
                            alert(textStatus);
                        }                });            });
            </script>
        </head>
        
        <body>
          
        </body></html>
      

  3.   

    你返回json的格式的数据就好了。确认你的url 返回json。
      

  4.   

    楼主,你是不是想要说的是Ext的request请求跨域的问题 ?如果是,,可以换一种方式解决方案,让request先请求本地action,然后在action里面模拟post/get请求。
      

  5.   

    // 打开输出
    public void openWriter(HttpServletResponse resp) {
    try {
    resp.setCharacterEncoding("utf-8");
    resp.setContentType("text/html;charset=utf-8");
    out = resp.getWriter();
    } catch (IOException e) {
    MyUtil.printInfo("---------------------------openWriter IOException--------------------------------------- ");
    e.printStackTrace();
    }
    } // 关闭输出
    public void closeWriter() {
    if (out != null) {
    out.flush();
    out.close();
    }
    }out.print("要输出的信息");//这个就是respone