I recently came across a funny bug where I was executing an AJAX method and the response was empty.

I check the server side and I know that my particular query is returning a result, but thanks to Firebug I can see it's failing in the browser.

So there was something definitely amiss.

MY EVENTAttend ffconf.org 2018

The UK's best JS and web development conference. 8 amazing speakers, workshops, socials — find out more & get tickets today.

In particular, I was returning my result as a JSON object which should have looked like this:

{message: "Order Filled"}

However, Firebug was throwing the following error (within the jQuery library - but I had the same problem when I hadn't used a library):

syntax error data =

The problem is down to the size of the response. It's something like apache is compressing it to nothing. Not very technical I realise - but the solution is to pad the response.

I fixed it by placing a '\n' before the JSON - since it's legal syntax it doesn't cause a problem, and it means the response is read in the browser.

All was well again in the land of AJAX & Remy.

Want more?

Posts, web development learnings & insights, exclusive workshop and training discounts and more, direct to your inbox.

I won't send you any spam, and you can unsubscribe at any time. Powered by ConvertKit