javascript unexpected token < , is there any way I can escape the errors(or atleast skip those useless characters)
<p>In php, I have an array like this : </p>

<pre><code>$arr['a'] = "some big data so may contain some chars that bring us headache"
$arr['b'] = "some big data same as above"

$data = json_encode($arr)
echo $data
</code></pre>

<p>My javascript code containing a jquery ajax call, $.ajax . It calls the file containing the above php code so, on success, the json_encoded(by php) is returned to my javascript variable . In my javascript file, I am doing like this : </p>

<pre><code>jsdata = JSON.parse(data); //Getting error here

$.ajax({
type: "post",
data: jsdata,
url: "url",
crossDomain: true,
dataType: 'jsonp'
}).done(function(d) {
  print("success");
});
</code></pre>

<p>From the above code, in the line jsdata = JSON.parse(data), I am getting errors something like </p>

<pre><code>  Error :    UNEXPECTED TOKEN &lt;
</code></pre>

<p>As the data contains lot of different content, its normal to get those errors . They need to be escaped properly . Can anyone tell me how to do that correctly . Whatever the data may be , I shouldnot get error regarding the data . </p>

<p>Thanks</p>
