Reputation: 41
I'm using AJAX to send a request and response comes back as JSON. Some of our users have been complaining that they are getting error, which points to that the invalid JSON has been received. We checked on the server that the valid JSON is being sent. On debugging further, it was noticed that the following code is being appended to the JSON, making the JSON parsing fail.
<div id="isChromeWebToolbarDiv" style="display:none">
Actual JSON Sent:
{"err_code":"0", "errmsg":""}
JSON being received:
{"err_code":"0", "errmsg":""}<div id="isChromeWebToolbarDiv" style="display:none">
Any idea from where it is getting appended? What is causing it? How to prevent or work around it?
Best regards, Shishir
Upvotes: 4
Views: 817
Reputation: 1
I had the same problem. My solution was: Use plain text as ajax response (not JSON), than delete with regular expression data added by chrome, than convert it to JSON object with JSON library (download from https://github.com/douglascrockford/JSON-js).
$.ajax({
...
success: function(data){
data = data.replace(new RegExp("<div(.*)</div>"),'');
data = JSON.parse(data);
...
}
);
Upvotes: 0
Reputation: 315
This is caused by a Chrome extension called DVDvideosoftTB. It appears to append the above HTML to file upload requests. You can easily disable it:
One of our customers ran into this issue, and I found the solution on this page (In the "Browser Issues" tab then "Uploading in Chrome PC").
Upvotes: 2