【问题标题】:ajax not sending data to index.phpajax 不向 index.php 发送数据
【发布时间】:2017-03-04 07:52:42
【问题描述】:
$(document).on('click','.show_more',function(){
    var no = $(this).attr('id');
    $('.show_more').hide();
    $('.loding').show();
    $.ajax({
        type:'POST',
        url:'index.php',
        data:'id='+no,
        success:function(html){
            $('#show_more_main'+no).remove();
            $('.snne').append(html);
        }
    });
});

ajax 没有向 php 发送数据我正在尝试这个 echo $_POST["id"] 但我得到了通知:未定义的索引:id 错误也说 不推荐使用主线程上的同步 XMLHttpRequest

【问题讨论】:

    标签: ajax


    【解决方案1】:

    升级到 3.0 以上的 jquery 版本来解决这个问题。

    或者

    此解决方案仅适用于某些情况:

    使用done 方法代替success 方法。

    success:function(html){ 替换为done:function(html){

    编辑

    在您的代码async: true 中添加这一行。像这样:

    $.ajax({
            type:'POST',
            url:'index.php',
            asyc: true,//<---- insert this
            data:'id='+no,
    

    【讨论】:

    • 还是同样的问题
    • 又是同样的问题
    猜你喜欢
    • 2016-03-09
    • 2014-01-11
    • 1970-01-01
    • 2014-04-01
    • 2018-12-22
    • 2018-02-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多