Javascript 接收错误“;未捕获的TypeError:$.ajax不是函数;
我有一个表单,它通过ajax将用户信息发送到一个php文件,该表单位于引导模式上。我试图添加一个额外的字段,看看它是否更适合这个目的,但决定在表单完美工作之前去掉它。现在ajax没有向我的php文件发送信息。我收到开发人员工具中“uncaughttypeerror:$.ajax不是函数”的通知。我的代码中有错误吗 表格:Javascript 接收错误“;未捕获的TypeError:$.ajax不是函数;,javascript,php,jquery,ajax,twitter-bootstrap,Javascript,Php,Jquery,Ajax,Twitter Bootstrap,我有一个表单,它通过ajax将用户信息发送到一个php文件,该表单位于引导模式上。我试图添加一个额外的字段,看看它是否更适合这个目的,但决定在表单完美工作之前去掉它。现在ajax没有向我的php文件发送信息。我收到开发人员工具中“uncaughttypeerror:$.ajax不是函数”的通知。我的代码中有错误吗 表格: 关于 城市: 状态: 最喜爱的运动: 参加过上述运动: &时代; 更新关于 城市: 当我遇到这个问题时,我发现我包含了两次jQuery 检查呈现的HTML,并确保只包含一
关于
城市:
- 状态:
最喜爱的运动:
- 参加过上述运动:
&时代;
更新关于
城市:
当我遇到这个问题时,我发现我包含了两次jQuery
检查呈现的HTML,并确保只包含一次jQuery,它将修复它。我不确定是否是因为Bootstrap 4,但在我的情况下,将ajax脚本更改为以下操作有效:
https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
您正在jQuery顶部加载jQuery slim,从而删除$.ajax
。如果没有jQuery slim,就不要这样做。发布后立即隐藏我的modal。还有其他选择吗?谢谢大家,菲尔
function about(){
var updatedCity = $("#updatedCity").val();
var updatedState = $("#updatedState").val();
var x = document.getElementById("playedSelect");
var playedSelect = x.options[x.selectedIndex].value;
var p = document.getElementById("sportSelect");
var sportSelect = p.options[p.selectedIndex].value;
var usernameSubmitting = $("#usernameSubmitting").val();
var aboutForm = document.getElementById("aboutForm");
$.ajax({
url: "../php_parsers/updateabout_parse.php",
type: "POST",
data: {
updatedCity: $("#updatedCity").val(),
updatedState: $("#updatedState").val(),
sportSelect: $("#sportSelect").val(),
playedSelect: $("#playedSelect").val(),
usernameSubmitting: $("#usernameSubmitting").val()
}
}).done(function(result) {
if (result == "success") {
$("#successAlert").html("Update successful").show();
} else {
$("#updateFail").html(result).show();
}
})
$('#participantModal').on('hide.bs.modal', function (e) {
if(updatedCity != ""){
$("#city").html('City: <a href="#"> ' + updatedCity + '</a>');
}
if(updatedState != ""){
$("#state").html('State: <a href="#"> ' + updatedState + '</a>');
}
if(playedSelect != ""){
$("#participation").html('Has participated in sport above: <a href="#"> ' + playedSelect + '</a>');
}
if(sportSelect != ""){
$("#FavoriteSport").html('Favorite Sport: <a href="#"> ' + sportSelect + '</a>');
}
$("#successAlert, #updateFail, #warningAlert").hide();
aboutForm.reset();
});
}
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
include_once("../php_includes/db_conx.php");
$city = "";
$error = "";
$u = "";
$state = "";
$sportSelect = "";
$playedSelect = "";
$u = mysqli_real_escape_string($db_conx, $_POST['usernameSubmitting']);
if(!$_POST['updatedCity'] && !$_POST['updatedState'] && !$_POST['sportSelect'] && !$_POST['playedSelect']){
$error .= "No information was entered";
echo $error;
}else{
echo "success";
}
?>
https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js