繁体   English   中英

没有数据的ajax请求不起作用

[英]ajax request without data not working

我正在尝试使用ajax删除照片,并且删除照片后立即显示默认图像,到目前为止,我已经完成了php方面的工作,但是ajax部分无法正常工作。 我如何在没有数据类型的情况下发出Ajax请求?

function delete_image()
{
    $.ajax({
        type: "POST",
        url: "target.php?page=delete",
        cache: false,
        success: function(response)
        {  
            var $divs = $("<div>" + response + "</div>");
              $("#phd").fadeOut('slow');
            $(".suc_pic").fadeIn('slow').empty().append($divs.find("#msg"));//the default picture fades in once the photo is deleted.

           }
    });


}

尝试在数据部分移动“ page = delete”

function delete_image()
    {
        $.ajax({
            type: "POST",
            url: "target.php",
            cache: false,
            success: function(response)
            {  
                var $divs = $("<div>" + response + "</div>");
                  $("#phd").fadeOut('slow');
                $(".suc_pic").fadeIn('slow').empty().append($divs.find("#msg"));//the default picture fades in once the photo is deleted.

            },
            data: {page='delete'}
        });

    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM