Forums Register Login

Unable receive proper http status response from javascript

+Pie Number of slices to send: Send
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?



+Pie Number of slices to send: Send
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.

1
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.

Please do not shoot the fish in this barrel. But you can shoot at this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 709 times.
Similar Threads
Servlet and Ajax
How to display result of php file in an html file
call js function from <form> action
Basic XPath Sum question
jquery, ajax, servlet and null data in callback function
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 05:12:06.