weixin_33705053 2011-08-07 12:00 采纳率: 0%
浏览 19

在Ajax中获取数据不起作用

I have this Jquery Javascript code:

$(document).ready(function(){
    $("#check_button").click(function(){
        $.ajax({
            url: "includes/adcontent.php",
            type: "GET",
            data: "id=<?php echo $id; ?>",
            async: false,
            cache: false,
            beforeSend: function (data) {
                    $('#check_quest_button_div').html("<img src='/images/icons/loading.gif' title='Please wait' alt='Please wait' />");
            }
        });
    });
});

And this is my PHP code in includes/adcontent.php:

if (!isset($id) && isset($_GET['id'])){
    $id=htmlspecialchars(strip_tags($_GET['id']));
}
echo $id;

But with this code I have an error message. The script doesnt send the GET data. What is the problem?

  • 写回答

2条回答 默认 最新

  • derek5. 2011-08-07 12:05
    关注

    Try this

    $(document).ready(function(){
        $("#check_button").click(function(){
            $.ajax({
                url: "includes/adcontent.php?id=<?php echo $id; ?>",
                type: "GET",
                async: false,
                cache: false,
                beforeSend: function (data) {
                        $('#check_quest_button_div').html("<img src='/images/icons/loading.gif' title='Please wait' alt='Please wait' />");
                }
            });
        });
    });
    
    评论

报告相同问题?

悬赏问题

  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建