如何在html表单中使用该操作,以便我可以从表单中发送所有数据
我试过$("#formupload").attr('action')
似乎无法正常工作
这是我的代码:
$(".clickupload").click(function () {
$("#dialog-form").dialog("open");
});
$("#dialog-form").dialog({
autoOpen: false,
closeOnEscape: true,
title: "Upload Picture",
width: 400,
height: 300,
modal: true,
buttons: {
Cancel: function () {
$(this).dialog("close");
},
Upload: function () {
$(document).ready(function () {
$("#formupload").attr('action');
});
}
}
});
<div id="dialog-form">
<form id="formupload" action="ProfileImages/FileUpload.php" method="POST" enctype="multipart/form-data">
<input type="file" name="uploadProfilePicture"/>
</form>
</div>
答案 0 :(得分:1)
你的意思是$("#formupload").sumbit();
?你正在做的是读取属性然后对它做什么?
答案 1 :(得分:0)
只需尝试$("#formupload").submit()
答案 2 :(得分:0)
bweobi说了什么,并最终将所有jQuery初始化内容放在文档上,以确保在向其元素添加事件处理程序之前将文档全部初始化:
(function($) { // Allows you to create variables locally so
// there are no conflict with other stuffs.
$(document).ready(function() {
// You can name jQuery variables with a dollar so you can easily make
// the difference betwen jQuery and non-jquery objects.
$dialogForm = $('#dialog-form'); // Half queries, double speed.
$(".clickupload").click(function () {
$dialogForm.dialog("open");
});
$dialogForm..dialog({
autoOpen: false,
closeOnEscape: true,
title: "Upload Picture",
width: 400,
height: 300,
modal: true,
buttons: {
Cancel: function () {
$(this).dialog("close");
},
Upload: function () {
$("#formupload").submit();
}
}
});
});
})(jQuery); // Alows you not to use $ in global scope in case
// you use multiple libraries that use the $.