我一直在嘗試在過去的幾天裏,在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