我正在为评论系统设置一个Ajax代码,为产品排序设置另一个代码,但是只有在我离线时才能使用
我尝试了另一个浏览器,但是是相同的问题,但是我在控制台中发现了此错误,但是我的代码中没有看到任何错误:Uncaught TypeError:$ .ajax不是一个函数 在HTMLInputElement。
这是我对产品进行排序的代码:
<script>
$(document).ready(function(){
$(document).on('change', '#choix', function() {
var choix = $(this).val();
var id = <?php echo intval($_GET['id']); ?>;
$.ajax({
url:"../Ressources/sort_products.php",
method:"POST",
data:{choix:choix,id:<?php echo intval($_GET['id']); ?>},
success:function(data){
$('#show_product').html(data);
}
});
});
});
</script>
这是注释的代码:
<script>
$(document).ready(function(){
$('#submit').click(function(){
var id = <?php echo $id; ?>;
var commentaire = $('#commentaire').val();
$.ajax({
url:"add_comment.php",
method:"POST",
data:'id='+id+'&commentaire='+commentaire,
success:function(data)
{
$('#comment_form')[0].reset();
alert("Votre commentaire a été ajouté");
load_comment();
}
})
});
load_comment();
function load_comment()
{
var idp = <?php echo $id; ?>;
$.ajax({
url:"fetch_comment.php",
method:"POST",
data:{idp},
success:function(data)
{
$('#display_comment').html(data);
}
});
}
$(document).on('click', '.delete', function(){
var id = $(this).attr("id");
$.ajax({
url:"../Ressources/delete_comment.php",
method:"POST",
data:{id:id},
success:function(data){
alert("Votre commentaire a été supprimé");
load_comment();
}
});
});
});
</script>
答案 0 :(得分:0)
问题是您使用的是jQuery的精简版,其中一些内容已删除,只需下载jQuery here的常规版(压缩版或未压缩版)并将其包含在项目中即可。
slim版本通过排除ajax和effects模块来减轻重量(普通版本的文件大小)。