簡體   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