我一直在尝试在过去的几天里,在jQuery中序列化一个表单,并将它传递给php。出于某种原因,它只是不工作...问题,你采取什么步骤序列化在JQuery中的表单...我得到表单的ID传递到$('#fomrID')。serialize()。 ..在jQuery中序列化表单并将其传递到php
而且它仍然不起作用。当我用萤火虫调试时我所得到的只是一个空字符串...你使用表单的名称或ID。你使用e.disableDefalut或者其他什么?我想不通,为什么我不能序列我的表格请帮助
$('#profilepicbutton').change(function(){
alert("Boy I hate PHP");
var formElement = $('#profilepicinput').attr('value');
dataString = $("#registerpt3").serialize();
$.ajax({
type: "POST",
url: "register3.php",
data: dataString, //"profilePic="+formElement,
success: function(data){
alert("Data Saved: " + data);
$.ajax({
type: "POST",
url: "retrievePic.php",
data: "",
success: function(data){
alert(data);
var image = new Image();
$(image).load(function(){
console.log("we have uploaded this image");
}).attr('src', 'images/');
alert("");
},
error: function(msg){
alert("");
}
});
},
error:function(msq){
alert("" + msg);
}
}
);
});
<form id="registerpt3" name="registerpt3" enctype="multipart/form-data" action="register3.php" onSubmit="" method="post">
<input name="profilepicinput" type="file" id="profilepicbutton" />
</form>
你还没有声明dataString。 – Mark