日期:2014-05-16  浏览次数:20690 次

ajax跨域请求
求大神普及下这个怎么弄,最好写个测试过的代码!备注请详细标明。。。由于本人是新手望大神们见谅!能测试通,而且备注能教我这个菜比看懂果断100
------解决方案--------------------
【ajax跨域请求JSONP】

------解决方案--------------------
<!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/>");                            
                        }