I’m having a problem within the jQuery ajax function. The following code works fine in Mozilla but doesn’t work in IE or Chrome, when I try to identify the problem using Developer Tools in chrome I get the error:
Uncaught SyntaxError: Unexpected token ILLEGAL \n
$.ajax.success
and when I click on it it directs me to the var obj = JSON.parse(data); line.
function getdata(){
$.ajax({
type:"GET",
url: "https://gdata.youtube.com/feeds/api/users/TheSyndicateProject/playlists?v=2&alt=jsonc",
data: "",
success: function(data) {
var obj = JSON.parse(data);
displayPlaylists(obj);
}
});
}
EDIT:
Ive found a solution that works in chrome but still not in IE
function getdata(){
$.ajax({
type:"GET",
url: "https://gdata.youtube.com/feeds/api/users/TheSyndicateProject/playlists?v=2&alt=jsonc",
dataType:"json",
success: function(data) {
displayPlaylists(data);
}
});
}
the addition of dataType:”json” means that the function expects json data to be returned and therefore parses it on arrival (it is equivalent to using jQuery.parseJSON), however as i said this solution still doesn’t work in IE
set dataType to json and browser will automatically parse json for you, see if it works for you