2014-03-12 91 views
0

我想刪除照片使用ajax和當照片被刪除時顯示默認圖像即時,到目前爲止我用PHP端完成,但ajax部分不工作。我怎樣才能做一個沒有數據類型的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. 

      } 
    }); 


} 
+1

這應該工作。你認爲這不是什麼方式? –

+0

@KevinB當我點擊刪除按鈕什麼都沒有發生,我想它不是發送請求到PHP頁面。 – user3412305

+0

進一步調試。進入事件處理程序有多遠?如果它從來沒有成功回調,它會得到錯誤回調? –

回答

-1

嘗試移動數據secction 「頁=刪除」

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'} 
     }); 

    }