Tuesday, 17 September 2013

Reading cross domain csv file using JSONP and AJAX

Reading cross domain csv file using JSONP and AJAX

Trying to read cross domain csv file
remote_url =
"http://www.example.com/buglist.cgi?bug_status=NEW&columnlist=bug_id%2Cshort_desc&query_format=advanced&ctype=csv";
$.ajax({
url:remote_url,
type:"get",
cache: false,
dataType: "jsonp",
success:function(data){
console.log(data);
},
error: function(data){
console.log(data);
}
});
Although getting 200 status from server, It always going into error
callback handler and logging javascript syntax error
SyntaxError: missing ; before statement 6230,"this is a ""short
description"", blah blah blah..
My csv file has two columns "bug_id" and "short_desc" with following
values bug_id = 6230 short_desc = this is a "short description", blah blah
blah..
I know the error is because of double quote in description, but I don't
know the solution. Tried "YQL" to convert csv to json but it returned null
as a result, may be because of error. Thanks,

No comments:

Post a Comment