I am using ajax call on a PHP file which contains folling code:
echo str_replace(array("\x1e", "\x1c"), "", file_get_contents('http://www.domain.com/getJsonDocuments?categoryBranch='.intval($_GET['category'])));
The problem now is that in those JSON Documents, there are many invisible or special Characters not only the two you can see in code above, which I already str_replace:
array("\x1e", "\x1c")
If I do not replace them, the error function of the ajax call is fired:
$.ajax({
type: 'GET',
url: 'jsonrequestCategory.php',
dataType: 'json',
success: function(data) {
console.log('success');
},
error: function() {
console.log('error');
}
});
So my question is:
Is there a way to get rid of all those characters somehow? Or do I need to check every Document and every char to avoid getting an error?