Skip to Content Skip to Menu

jSON IE bug jquery .ajaxSubmit() - badly formed jSON

Background

Recently came across this problem, on a site that was already programmed by someone else, which turned out to be something simple in the end. There was a click event on a submit button that would then fire off an ajaxSubmit with a jSON response. Now this was working in all Firefox browsers but failing in all IE browsers. The same jquery code was actually working on another form on the same site... so that brought on the suspicion that there was something wrong with the jSON.

Here an example of the jSON response:

[{"Errors": "An error has occured - blah blah blah", }]

Solution

Culprit was the extra comma at the end of the string. Because there is no more items in the array, there shouldn't be a comma there. Might I note, this was very hard to debug in IE as it didn't submit the form or appear to be running the ajaxSubmit.