0

I am using apache httpd server for serving my html files i.e. localhost:8087

My Node.js server is running in someip:8010.

I am sending a simple Ajax request from localhost:8087 to someip:8010 and waiting for response from server but:

case 1 : when response comes before 1 minute every thing is working perfectly fine .

Or...

case 2 : when response takes more than 1 minute, then in my chrome console it says

XMLHttpRequest cannot load http://someip:8010/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8087' is therefore not allowed access.

And the Ajax error object is:

{"readyState":0,"responseText":"","status":0,"statusText":"error"}

And after that it is not receiving any response from server.

Whereas the server is running perfectly fine and no error is shown on server side, and after 3 minutes when server is sending response my client is not receiving .

1 Answer 1

0

There can be more reasons for this. The first reason is: does your you make a request to allow you to process for such a long time. Or the problem could be jquery. It is possible to change the timeout in jquery. For that you have 2 options:

  • For the specific request use:

$.ajax("http://example.com:8081",{timeout:120000})

  • For all requests use:

$.ajaxSetup({timeout:120000}

The number is the time in miliseconds.

10
  • i used this also but it is not working at all. do we need to give this somewhere in http.conf file
    – Rahul
    Dec 12, 2014 at 4:32
  • moreover the error is not timeout rather :{"readyState":0,"responseText":"","status":0,"statusText":"error"}
    – Rahul
    Dec 12, 2014 at 4:50
  • Could it be that the problem is not the time of a minute, but the amount of data you are trying to send?
    – Mark Smit
    Dec 12, 2014 at 9:06
  • the data is hardly 0.5 kb, but the matter is my server is still working and sending response after 3 minutes but browser is showing error after one minute and not listening for any further response.
    – Rahul
    Dec 12, 2014 at 9:12
  • Does the firewall allow you to communicate to the ports from outside? Does the software the request method you are trying (post/get/put/delete)? this looks like the request is blocked in some way.
    – Mark Smit
    Dec 12, 2014 at 9:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.