2014-10-26 70 views
0

我返回一個有效載荷,而不是一種形式的數據,我不能檢索與PHP 我需要一個崗位類型FORMDATA的值,但我無法弄清楚如何AJAX返回的有效載荷,而不是形式的數據

$('#send_avatar').click(function(){ 

     var x=document.getElementById("x").value; 
     var y=document.getElementById("y").value; 
     var w=document.getElementById("w").value; 
     var h=document.getElementById("h").value; 

     var fd = new FormData();  

     //fd = 'x=' + x + '&y=' + y + '&w=' + w + '&h=' + h ; 

     fd.append('file', $('#uploadImage')[0].files[0]); 
     fd.append('x', x); 
     fd.append('y', y); 
     fd.append('w', w); 
     fd.append('h', h); 



     $(".ris").html("<img src='images/loading.gif' height='30px'>");   


     //dataString.append("image", immagine); 

     $.ajax({ 
     type: "POST", 
     url: "funzioni/upload_avatar.php", 
     data: fd, 
     async: false, 
     cache: false, 
     contentType: "X-Requested-With:XMLHttpRequest", 
     processData: false,   
     success: function(response){ 
      $(".ris").html(response);    
     } 
     }); 

}); 

我該怎麼辦?

回答

1

此:

contentType: "X-Requested-With:XMLHttpRequest", 

是不是有效的內容類型。刪除該行。

+0

我試過了,但是..對我不起作用 – 2014-10-27 00:05:21

相關問題