Removing The First Line From A Json Response
My current code is : $.getJSON('https://www.domain.com/someapi/callback=?', function(data){ $.each(data, function(i,item){ alert(item.x); });
Solution 1:
Make a ajax normal request
$.ajax({
url : "https://www.domain.com/someapi/callback=?",
success : function(result){
// So here we get the result json with an error// So lets say the response is something like this/*
There was an error on line 35
{
json : true
}
*/// So we remove everything before the first '{'
result = result.replace(/[^{]*/i,'');
//We parse the jsonvar data = JSON.parse(result);
// And continue like no error ever happened
$.each(data, function(i,item){
alert(item.x);
});
}
});
I hope this work. (a cross domain request must be enabled from the server)
Post a Comment for "Removing The First Line From A Json Response"