How to handle bad call to

A weather reviewer tells me that my XMLHttpRequest() to \“GET”, “”, false) is not successful and returning errors. It works find from my location.
How to exit and return a brief message from that point. I tried to calling a function but it causes my Fahrenheit/Celsius not to work.
Let me know if it works for you. Thanks.

Sure, it works, but error handling is important. Can you share your code? Maybe move this over to a CodePen so it’d be easier to get help?

All the code is viewable using view source. I have images that I could not place on Thanks for the feedback.

You don’t need to place the images in CodePen. They’re already hosted on your server, so you can just refer to them with a link. Or you could just leave them out if they aren’t critical to solving the problem.

If you want people to help you debug your code, it’s courteous to provide your code. Expecting me to copy your source from the browser and set up an environment on my end means I have to do extra work to help you which, aside from being a bit rude, means you’re way less likely to get the help you want. This goes for anywhere you’d ask for help online, whether it’s here, reddit, or stackoverflow. For front end projects, having a CodePen handy makes it very easy for other people to help. Server-side code is more involved, but sharing a GitHub repo is sufficient.

Thanks for giving me the image solution. I am new at this! Spent so much time on the images.

Hi PortableStick,
I copied the code to

Still not sure why the images don’t show up here. Thanks any help is appreciated.

Your image URL needs to have “http://” at the start.

Also you’ve got your CSS in two different places, with codepen you can just put it all in the CSS section, no need to use inline styling :smiley:

Cool. So, adding error handling to native XHR objects can be tricky, but we can lump a lot of it together to save time. On line 106, you have the following:

if (whr.readyState == 4 && whr.status == 200)

If there’s an error with the HTTP transaction, then whr.readyState will be 4, but whr.status is not going to be 200. So, adding

if (whr.readyState == 4 && whr.status !== 200) {
  // other error handling

will allow you to handle errors by displaying status messages and informing the user what went wrong.

Thanks. I will add and test the change.