<!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。
发布于 2013-07-30 13:30:28
Access-Control-Allow-Origin报头需要由服务器发送。从客户端发送它不会做任何事情。您需要一个服务器端代理来解决跨域问题。
https://stackoverflow.com/questions/17938393
复制相似问题