Does ajax jump when it discovers error but fails?

ajax

 error: function(jqXHR, textStatus, errorThrown) {
      errorGo(textStatus, errorThrown);
    },

errorGO ()

function errorGO(status, error){
  console.log("textStatus: %s, errorThrown: %s", status, error, location, type);
  alert("Something went wrong :(");
  $.ajax("https://xx.x.com/x/query.php", {
    type: "POST",
    data: {
      "message": status,
      "error": error
    },
    dataType: "text",
    crossDomain: true,
    success: function(){
      location.href = "/wrong";
      console.log("go /wrong");
    }
  });
  return;
}

query.php

 status  error 

the weird thing is: make sure there are profitable databases. But did not perform the location.href ="/ wrong"; jump?
where is the problem? Or is there a better way to avoid this problem?


Hello, landlord! Confirm whether the request is successful. If it is successful, the success method has been executed. You can go under console.log () . You can also release the fail method and execute


you delete the return and try


according to your code, there are two possibilities:

  1. alert is on Synchronize, which blocks the execution of later code, so it doesn't jump
  2. .
  3. the second ajax returns a failure

if you click alert the pop-up box does not jump, that's the second reason; if you don't click on the pop-up box, it certainly won't jump, and that's the first reason.

Menu