In my case, it was because the AJAX call was being blocked by the browser because of the same-origin policy. It was the least expected thing, because all my HTMLs and scripts where being served from 127.0.0.1
. How could they be considered as having different origins?
Anyway, the root cause was an innocent-looking <base>
tag:
<base href='<%=request.getScheme()%>://<%=request.getServerName() + ":" + request.getServerPort() + request.getContextPath()%>/'/>
I removed the <base>
tag, which I did not need by the way, and now it works fine!