Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Unable receive proper http status response from javascript  RSS feed

 
Arnob Dey
Ranch Hand
Posts: 34
Eclipse IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I need help on a piece of JavaScript. The IP and the port is correct and we are able to get a sample text in response when we hit http://<IP>:<port>; on browser. But the below function is returning "failed. HTTP status : 0". Can anyone please help?



 
Arnob Dey
Ranch Hand
Posts: 34
Eclipse IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tim,

My sincerest Apologies. Didn't realize that. Thanks for editing my original post. I'll make sure my posts don't reflect any urgency going forward. Thanks again.

 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anyway, about your question... it looks to me like maybe the request isn't being sent at all. Or maybe your code is checking for the result before the request is sent. Or maybe your browser doesn't support XMLHttpRequest or doesn't work with it the way you think it does.

But programmers haven't seriously used XMLHttpRequest for years now. Everybody uses somebody else's code which does the same thing only it's been tested in many different browsers. Of those, jQuery seems to be the commonest but I might be out of touch with the field. I'd suggest you don't spend a lot of time trying to debug XMLHttpRequest in your browser, just use jQuery or something similar.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65824
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, life is too short to waste it debugging code like yours. There are any number of libraries that will do Ajax calls for you, but of them, jQuery is the most widely used and the most approachable.
 
Arnob Dey
Ranch Hand
Posts: 34
Eclipse IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your time Paul and Bear. Much appreciated.

About the issue, it turns out that we ran into classic CORS (Cross Origin Resource Sharing). Anyways we have added appropriate headers to resolve it.

Apologies if I have unintentionally wasted your time. Going forward I'll be sure to post more sensible and appropriate questions.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!