if和else语句在ajax中不起作用

时间:2017-11-20 16:50:06

标签: jquery ajax

这是我的jquery函数。我可以成功获得正确的价值 当我使用if和else语句中的值时,它不起作用

function retrieveData() {
  $.ajax({
    type: "GET",
    url: 'http://localhost/DB/login.php',
    data: {
      email: $("#email").val(),
      pass: $("#pass").val()
    },
    success: function(data) {
      var response = data;

      if (response == 'Employee') {
        window.location.href = "#employees_details";
      } else if (response == 'Employer') {
        window.location.href = "#job_details";
      } else {
        alert(error);
      }
    }
  });
  //this is mandatory other wise your from will be submitted.
  return false;

}

0 个答案:

没有答案