Reputation: 1275
Im using Zend Framework. Here's 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>
I use ajax to load content to modal dialog (edit-add-form div element) from addForm.phtml:
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');
}
}
});
}
});
}
Here's 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">
But when I hit the submit button, just only the text input posted, but the file input didnt. It's weird huh?
Need your help so much. Regard.
Upvotes: 0
Views: 933
Reputation: 18354
You're missing the success
handler. You should do:
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!
});
}
ADVICE: Use firefox's firebug Net panel to see if your file is really uploading
Hope this helps. Cheers
Upvotes: 1