Jquery file uploader blueimp, Unexpected Token/Character

Jeremy23 picture Jeremy23 · Nov 6, 2014 · Viewed 10.2k times · Source

First of all let me tell you that I've already searched for some answers, and while it helped me out a bit, my main problems remain unresolved.

I used the file uploader (Version 9.8.0) @ http://blueimp.github.io/jQuery-File-Upload/

(1st problem)
Everything seems to work fine until I start uploading. After it finishes uploading, it says the following error for each image (instead of the "upload successful" message).

On Google Chrome it says: "SyntaxError: Unexpected token <"
on Mozilla FireF. it says: "SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data"

I searched some solutions but I can't figure out how to apply these solutions. And btw, it adds the image, despite the error.

Answer

StephanC picture StephanC · Jun 10, 2015

The method you are calling is throwing an error page with html (starting with < and cannot be parsed in JSON), if you look at the network tab in your browser.

For example in Google Chrome:

  1. Open debugger: F12
  2. Go to network tab
  3. Do the upload
  4. You should see the request that was sent in the Network tab
  5. Click on that error request
  6. That will open a new window with a tab for the response from the server. This response will most likely be some kind of exception message.

I had a similar problem on ASP.Net MVC with a different uploader, when one of the parameters was sent as null and it wasn't nullable on the controller.