PHP Jquery Ajax call throws net::ERR_EMPTY_RESPONSE

前端 未结 8 1299
时光说笑
时光说笑 2020-12-02 18:43

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

相关标签:
8条回答
  • 2020-12-02 19:36

    I believe your request is not classed as a "simple request" under the CORS specification:

    http://www.w3.org/TR/cors/#simple-cross-origin-request-0

    since you are setting a response header for Content-Type: application/json.

    So your server will need to handle the preflight request, which involves setting some additional headers on both the request and response for the CORS request to be successful

    Here is a good article on what you need to do - check out the bit under "not so simple":

    http://www.html5rocks.com/en/tutorials/cors/

    0 讨论(0)
  • 2020-12-02 19:41

    I was having this same error and was able to fix it by sending all the data I need to process in an array to the server, and then having it spit the updated array back to the client, so that only one AJAX call is made.

    I wasn't able to determine the exact cause of this issue, but I'm pretty sure what's going on is that some sort of buffer is getting filled to capacity with all those AJAX calls, causing the server to shut down some of those requests.

    Hope this helps.

    0 讨论(0)
提交回复
热议问题