0
<!DOCTYPE html>

<html>

<head>

    <script src="jquery.js"></script>

    <script>

        $.ajax({            
            type: 'GET',
            url: 'http://dictionary-thesaurus.com/wordlists/Nouns%285,449%29.txt',
            contentType: 'text/plain',

            xhrFields: {withCredentials: true},

            headers: {'Access-Control-Allow-Origin':'*'},

            success: function (res) {
                var words = res.responseText.split("\n");
                alert("word : " + words[2]);
            }
        });
    </script>

</head>
<body>

</body>
</html>

//XMLHttpRequest 无法加载http://dictionary-thesaurus.com/wordlists/Nouns%285,449%29.txt

4

1 回答 1

0

Access-Control-Allow-Origin头需要由服务器发送。从客户端发送它什么都不做。您将需要一个服务器端代理来解决跨域问题。

于 2013-07-30T05:30:28.193 回答