No 'Access-Control-Allow-Origin' header is present on the requested resource.

来源:互联网 发布:申请淘宝达人的步骤 编辑:程序博客网 时间:2024/04/27 23:39

跨域请求的解决方案。

$.ajax({
        dataType: 'JSONP',
        type: "GET",
        url: "http://dzd.wddcn.com/vshop/addr.html?action=region&level=3&value=" + district.value,
        success: function (tjson) {
            if (region_cb) {
                 region_cb('t', tjson);
            }
            for (var i = 0; i < tjson.length; i++) {
                town.options.add(new Option(tjson[i].name, tjson[i].id));
            }
            if (arr.length > 3 && arr[3] != "" && arr[3] != "-1") {
                town.value = arr[3];
            }
        }
    });

如果用ajax请求type改成JSONP就可以了。

0 0