0

I have a function like this:

function checkAvailability() {
  try {
    $.ajax({
      type: "GET",
      url: `https://www.example.com/?....`,
      success: function (response) {
        
       // continue with the response even if there is a 403 error
        
      },
    });
  } catch (error) {
    console.log(error);
  }
}

And im expecting a 403 error and want to continue with the response of this request (not with the errors from js). JS stops working and i can't continue working with the response.

And chance to ignore a 403 erro in ajax calls ?

boran k
  • 13
  • 2
  • Please look at this: https://stackoverflow.com/questions/4282151/is-it-possible-to-ping-a-server-from-javascript – itzikb Jan 18 '21 at 21:12
  • @itzikb thank you but that's not what I was looking for. Don't want to see if a server is online or not. I'm requesting a server for a specific response, and sometimes it gives a 403 (but content is the same). And I want to use the response and work with it in other functions but js stops working when my ajax gets 403 error. – boran k Jan 18 '21 at 21:21
  • can you share the website that give you back 403? – itzikb Jan 18 '21 at 21:26
  • no unfortunately not. But i think thats not that important. The server return a 403 with some content and i want to work with this content. – boran k Jan 18 '21 at 21:30
  • Maybe try with this [answer](https://stackoverflow.com/a/8866912/2159528) and replace `200` with `403`... jQuery Ajax has some built in feature to split the `success` and the `errors`. ;) – Louys Patrice Bessette Jan 18 '21 at 21:52

0 Answers0