Php 为什么Ajax只有在禁用internet时才能工作?
我正在为评论系统设置一个Ajax代码,另一个用于对产品进行排序,但它只在脱机时起作用 我尝试了另一个浏览器,但也是同样的问题,我在控制台中发现了这个错误,但在我的代码中没有发现任何错误:uncaughttypeerror:$。ajax不是一个函数 在HTMLInputElement 以下是我的产品分类代码:Php 为什么Ajax只有在禁用internet时才能工作?,php,ajax,Php,Ajax,我正在为评论系统设置一个Ajax代码,另一个用于对产品进行排序,但它只在脱机时起作用 我尝试了另一个浏览器,但也是同样的问题,我在控制台中发现了这个错误,但在我的代码中没有发现任何错误:uncaughttypeerror:$。ajax不是一个函数 在HTMLInputElement 以下是我的产品分类代码: <script> $(document).ready(function(){ $(document).on('change', '#choix', fu
<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>
$(文档).ready(函数(){
$(document).on('change','#choix',function(){
var choix=$(this.val();
变量id=;
$.ajax({
url:“../resources/sort_products.php”,
方法:“张贴”,
数据:{choix:choix,id:},
成功:函数(数据){
$('show#u product').html(数据);
}
});
});
});
这是评论的代码:
<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>
$(文档).ready(函数(){
$(“#提交”)。单击(函数(){
变量id=;
var commentaire=$('#commentaire').val();
$.ajax({
url:“add_comment.php”,
方法:“张贴”,
数据:'id='+id+'&commentaire='+commentaire,
成功:功能(数据)
{
$('#注释形式'[0].reset();
警惕(“Votre commentaire aétéajouté”);
加载注释();
}
})
});
加载注释();
函数加载_注释()
{
var-idp=;
$.ajax({
url:“fetch_comment.php”,
方法:“张贴”,
数据:{idp},
成功:功能(数据)
{
$('#display_comment').html(数据);
}
});
}
$(文档)。在('单击','删除',函数()上){
var id=$(this.attr(“id”);
$.ajax({
url:“../resources/delete_comment.php”,
方法:“张贴”,
数据:{id:id},
成功:函数(数据){
警报(“Votre commentaire aétéSupplime”);
加载注释();
}
});
});
});
问题在于您使用的是精简版jQuery,删除了一些内容,只需下载jQuery的常规(压缩版或非压缩版)并将其包含在项目中即可
超薄版通过排除ajax和effects模块来减轻重量(普通版的文件大小)。打开浏览器检查器网络选项卡(Firefox/Chrome中的ctrl+shift+c)看看你犯的错误getting@glyph我复制了下面的错误您是否尝试过清除web浏览器缓存或尝试使用其他web浏览器您使用的是哪个版本的jquery我使用的是jquery v1.11.1尝试使用1.5或更高版本