Javascript ajax返回有效负载而不是表单数据

Javascript ajax返回有效负载而不是表单数据,javascript,php,jquery,ajax,forms,Javascript,Php,Jquery,Ajax,Forms,我返回一个有效负载,而不是表单数据,因此无法检索这些值​​使用php 我需要一个post类型formdata,但我不知道如何 $('#send_avatar').click(function(){ var x=document.getElementById("x").value; var y=document.getElementById("y").value; var w=document.getElementById("w").value;

我返回一个有效负载,而不是表单数据,因此无法检索这些值​​使用php 我需要一个post类型formdata,但我不知道如何

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

 });
$('send#u avatar')。单击(函数(){
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=新FormData();
//fd='x='+x+'&y='+y+'&w='+w+'&h='+h;
fd.append('file',$('#uploadImage')[0].files[0]);
fd.追加('x',x);
fd.追加('y',y);
fd.追加('w',w);
fd.追加('h',h);
$(“.ris”).html(“”);
//附加(“图像”,immagine);
$.ajax({
类型:“POST”,
url:“funzioni/upload_avatar.php”,
数据:fd,
async:false,
cache:false,
contentType:“X-request-With:XMLHttpRequest”,
processData:false,
成功:功能(响应){
$(“.ris”).html(回复);
}
});
});
我该怎么做?

这个:

contentType: "X-Requested-With:XMLHttpRequest",
不是有效的内容类型。拆下那条线