I have the following JavaScript code in the page. When the ajax call is made, I could see that the browser inspect/debugger section throws net::ERR_EMPTY_RESPONSE
I have same problem on my page sometimes. I think this happens because of number of variables or how big they are. I have a page that sends a json of about 250 variables without any problem, but this error occurs in this page while about 1500 variables are to be sent. This problem is new. Every thing even with 3000 variables were without problem, before. This problem occurs for me both in chrome and firefox in recent versions. It's not server side error because I have configured apache to revive 1 million variables of 30 Mb data.
I found same issue due to my network problem, may be your network also causing this.
I have been able to resolve this in most cases with a simple function that I wrote to dump/reset all garbage memory and flush/reset the output memory after any/all loops.
function memes(){
ob_flush();
ob_end_flush();
gc_collect_cycles();
ob_start();
gc_enable();
}
I was also getting the same error while using XMLHttpRequest().
However I was able to resolve the error by disabling memory limit for the script on the server side.
This is done by setting memory_limit to -1 in the php.ini file. By default it is set to 128M, so you may also try increasing the memory size rather than completely disabling it as it may take a lot of server's resources.
So this can happen for a number of reasons regardless of language or technology being used. I have encountered this with extremely small payloads of 15-20 data points being sent back and forth using angular resource. PHP, Jquery, Angular all handle the error differently but the results down to one of three things happening.
Latency or Network issues, I have had this happen on extremely slow connections, again this could be anything to a bad router or improper firewall configuration to just on a crappy network, to programs like avast that put a proxy in place to protect you from viruses.
High server load, I have forced a server to be at 100% cpu from stress testing and this will happening on random calls because the server is not handing the requests fast enough. This is hard to fix and really is a scaling issue for the system.
Huge Data Sets, large items being sent that the response fails, usually this can be fixed by adjusting your timeout settings on whatever web server you are using.
I had same problem. i tried many solution advice but nothing worked. Finally i was able to fix this issue by using Ajax Get method instead post. But prefer this if you dont send sensitive data.