无法通过ajax请求获取CSV文本 [英] Cannot get CSV text via ajax request
问题描述
我有一个问题不能检索csv响应。
I have a little problem of not being abble to retrieve csv response.
这里有一个csv可用 link to csv
There is a csv available here link to csv
我正在尝试检索此数据,
I am trying to retrieve this data, however there is a problem with special characters in the reponse.
我成功接收了数据,但是jQuery试图解码它,并通过语法错误:
我的请求是:
I successfuly recieve the data but then jQuery tries to decode it and through a syntax error: My request is:
$.ajax({
url: 'http://toolserver.org/~daniel/WikiSense/Contributors.php?wikilang=en&wikifam=.wikipedia.org&page=Cloud+computing&since=&until=&grouped=on&order=-edit_count&max=1000&order=-edit_count&format=csv',
dataType: "script",
success: function(data){
alert('success');
},
error: function(test1, test2, test3) {
alert('error');
}
});
错误是(指向%字符)
SyntaxError: syntax error
1004+%28922%2F82%29,SamJohnston,2008-07-26+09%3A40,2013-03-07+18%
我还试图将dataType设置为text,以便不解码数据。在这种情况下,我得到ajax请求的错误。
I also tried to set the dataType to text in order to not decode the data. In this case I get an error for the ajax request.
$.ajax({
url: 'http://toolserver.org/~daniel/WikiSense/Contributors.php?wikilang=en&wikifam=.wikipedia.org&page=Cloud+computing&since=&until=&grouped=on&order=-edit_count&max=1000&order=-edit_count&format=csv',
dataType: "text",
success: function(data){
alert('success');
},
error: function(test1, test2, test3) {
alert('error');
}
});
我试着尝试.ajax()参数contentType,dataType,scriptCharset等。 。
I tried to experiment with .ajax() parameters contentType, dataType, scriptCharset etc. It does not help.
推荐答案
在我看来,这是一个跨域请求是不可接受的。请阅读此处和此处了解详情
It seems to me that this is a cross-domain request which is not acceptable. Read here and here for more info
这篇关于无法通过ajax请求获取CSV文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!