I m using jQuery s ajax function to hit a cross domain url. The url will return json. I m in the discovery phase with this but I think, because the json values contain several " strings, the json eval is throwing an error and stopping the execution of my client side script. The error that I get is "unterminated string literal". I know that if I hard-code the returned json by putting it in a local div and remove the " strings (and a couple of hidden special characters), I can get the json to eval successfully. Whether through work-around, or through a correction to my code, what can I do to get the json from the url and store it in my client side javascript as a valid json object?
my current code. none of the defined functions (success, complete, error, dataFilter) execute:
$(function() {
$.ajax({
url: "http://www.codemash.org/rest/sessions.json?format=jsonp&callback=?",
dataType: "jsonp",
success: successFunc,
complete: completeFunc,
error: errorFunc,
dataFilter: dataFilterFunc
});
});
function successFunc() { console.log( successFunc(). enter. ); }
function completeFunc() { console.log( complete(). enter. ); }
function errorFunc() { console.log( errorFunc(). enter. ); }
function dataFilterFunc(data, type) {
data.replace(/W/g, );
return data;
}