JQuery JSON parse error – “Uncaught SyntaxError Unexpected Token u”

Jquery-JSon.parseI was working on a bootstrap modal that posted the form via AJAX. On submit, I checked for the success/failure of the form post, then (if successful) hide the modal. Otherwise, leave the modal and display an error Toastr message.

But I had this JQuery error that I couldn't quite trap and it was driving me bananas.

After some reading (quite a lot of reading), I found this JQuery bug report - http://bugs.jquery.com/ticket/13412. While there is a debate as to whether the issue is actually a bug or not, the most important part of that report is the reference to the JQuery Migrate script.

JQuery Migrate - http://blog.jquery.com/2013/05/08/jquery-migrate-1-2-1-released/ - is like a cumulative bundle of fixes for the 1.9 and 2.0 library.

This minor update addresses regressions created by the security fix in the 1.2.0 release that rejected some valid HTML strings. Many thanks to GitHub users gerrod, basc, Leonya, krzyko, and lorddefinitia for reporting these issues.

I included the JQuery Migrate script in my page and the JSON error went away. Feel free to let us all know if this fixes your issues or not.

Til next time ...