我正在使用Zend Framework。 这是index.phtml:
<div id="edit-add-form" title="Insert">
<form id="main-form" name="main-form" action="" method="post" enctype="multipart/form-data">
</form>
</div>
<a onclick="openAddPopup()">Open Popup</a>
我使用ajax将内容从addForm.phtml加载到模态对话框(edit-add-form div元素):
openAddPopup = function(){
$.ajax({
type: "POST",
url: '<?php echo $this->baseUrl()?>/core/database/landmark',
data: "&act=insert",
success: function(result,status,xResponse) {
$("#main-form").html(result);
$("#edit-add-form").dialog({
autoOpen: true,
title: 'Insert Data',
width: $(window).width()-20,
height: $(window).height()-20,
resizeable: false,
buttons: {
'Insert' : function() {
validateLForm();
}
,
Cancel: function() {
resetAllField();
$(this).dialog('close');
}
}
});
}
});
}
这是addForm.phtml:
<input type="text" id="l_name" name="l_name">
<input type="file" id="l_image" name="l_image">
<input type="submit" name="upload" id="upload" value="Upload Image">
但是当我点击提交按钮时,只发布了文本输入,但文件输入没有。这很奇怪啊?
非常需要你的帮助。 方面。
答案 0 :(得分:1)
您错过了success
处理程序。你应该这样做:
openAddPopup = function(){
$.ajax({
type: "POST",
url: '<?php echo $this->baseUrl()?>/core/database/landmark',
data: "&act=insert",
success: function(result){ //This line!!!
$("#main-form").html(result);
$("#edit-add-form").dialog({
autoOpen: true,
title: 'Insert Data',
width: $(window).width()-20,
height: $(window).height()-20,
resizeable: false,
buttons: {
'Insert' : function() {
validateLForm();
}
,
Cancel: function() {
resetAllField();
$(this).dialog('close');
}
}
});
} //This line also!
});
}
建议:使用firefox的firebug Net面板查看您的文件是否真的上传
希望这会有所帮助。干杯