未捕获的TypeError:$ .ajax不是函数,尽管包含了库

时间:2018-11-21 09:27:38

标签: javascript php jquery ajax

在查看控制台时出现此错误:

  

index.php:199未捕获的TypeError:$ .ajax不是函数
  在checkemail(index.php:199)
  在HTMLInputElement.onkeyup(index.php:232)

尽管我已在页面上添加了jQuery库:

function checkemail() {
  var email = document.getElementById("Email").value;

  if (email) {
    $.ajax({
      type: 'post',
      url: 'check_data.php',
      data: {
        email: email,
      },
      success: function(response) {
        $('#email_status').html(response);
        if (response == "OK") {
          return true;
        } else {
          return false;
        }
      }
    });
  } else {
    $('#email_status').html("");
    return false;
  }
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<p>
  <input type="email" placeholder="Email" id="Email" onkeyup="checkemail();" oninput="this.className = ''" name="email" required>
  <span id="email_status"></span>
</p>

0 个答案:

没有答案