求助!!!Form表单提交的问题
时间:2009-07-30
来源:互联网
大家好,请教一个问题:
现在我是通过jquery ui dialog实现了这样一个表单,如下:
<div id="dialog" title="添加新文件">
<p id="validateTips">所有项必填</p>
<form id="uploadForm" method="post" multipart/form-data" autocomplete="off">
<fieldset>
<label for="questions" >名称:</label>
<input type="text" name="myname" id="myname" class="text ui-widget-content ui-corner-all" autocomplete="off"/>
<label for="test_content" >描述:</label>
<input type="text" name="descript" id="descript" class="text ui-widget-content ui-corner-all" />
<label for="result" >文件:</label>
<input type="file" name="uploadfile" id="uploadfile"/>
<img id="loading" src="/../images/loading.gif" style="display:none;">
<label for="star">难度级别:</label>
<input class="star" type="radio" value="1" name="filelevel" style="display: none;"/>
<input class="star" type="radio" value="2" name="filelevel" style="display: none;"/>
<input class="star" type="radio" value="3" name="filelevel" style="display: none;" checked="checked"/>
<input class="star" type="radio" value="4" name="filelevel" style="display: none;"/>
<input class="star" type="radio" value="5" name="filelevel" style="display: none;"/>
</fieldset>
</form>
</div>
<button id="create-user" class="ui-button ui-state-default ui-corner-all">添加新内容</button>
下面的这部分代码是针对这个dialog的一些操作的:
jQuery( function($) {
$("#dialog").dialog( {
bgiframe : true,
autoOpen : false,
height : 500,
width : 600,
modal : true,
buttons : {
'提交' : function() {
$.ajax({
type: "POST",
url: "/file/index/add",
dataType: "json",
success:function(){
alert("添加成功!");
},
error:function(){
alert("添加失败!");
}
});
},
'重置' : function() {
$("#uploadForm").each( function() {
this.reset();
});
},
'关闭' : function() {
$(this).dialog('close');
}
}
});
$('#create-user').click( function() {
$('#dialog').dialog('open');
$("#uploadForm").each( function() {
this.reset();
});
});
}
请大家看一下“提交”这部分,现在的问题是,我要实现文件的上传和一些其他文本内容表单的处理,但是在.ajax提交数据的时候,我是提交到后台的PHP来处理的,现在却无法得到这些表单的值,请问这个如何处理呢?
因为我没有直接写表单的<input type="submit">所以在这不知该如何获取这些表单的值了?
请各位指教,谢谢
现在我是通过jquery ui dialog实现了这样一个表单,如下:
<div id="dialog" title="添加新文件">
<p id="validateTips">所有项必填</p>
<form id="uploadForm" method="post" multipart/form-data" autocomplete="off">
<fieldset>
<label for="questions" >名称:</label>
<input type="text" name="myname" id="myname" class="text ui-widget-content ui-corner-all" autocomplete="off"/>
<label for="test_content" >描述:</label>
<input type="text" name="descript" id="descript" class="text ui-widget-content ui-corner-all" />
<label for="result" >文件:</label>
<input type="file" name="uploadfile" id="uploadfile"/>
<img id="loading" src="/../images/loading.gif" style="display:none;">
<label for="star">难度级别:</label>
<input class="star" type="radio" value="1" name="filelevel" style="display: none;"/>
<input class="star" type="radio" value="2" name="filelevel" style="display: none;"/>
<input class="star" type="radio" value="3" name="filelevel" style="display: none;" checked="checked"/>
<input class="star" type="radio" value="4" name="filelevel" style="display: none;"/>
<input class="star" type="radio" value="5" name="filelevel" style="display: none;"/>
</fieldset>
</form>
</div>
<button id="create-user" class="ui-button ui-state-default ui-corner-all">添加新内容</button>
下面的这部分代码是针对这个dialog的一些操作的:
jQuery( function($) {
$("#dialog").dialog( {
bgiframe : true,
autoOpen : false,
height : 500,
width : 600,
modal : true,
buttons : {
'提交' : function() {
$.ajax({
type: "POST",
url: "/file/index/add",
dataType: "json",
success:function(){
alert("添加成功!");
},
error:function(){
alert("添加失败!");
}
});
},
'重置' : function() {
$("#uploadForm").each( function() {
this.reset();
});
},
'关闭' : function() {
$(this).dialog('close');
}
}
});
$('#create-user').click( function() {
$('#dialog').dialog('open');
$("#uploadForm").each( function() {
this.reset();
});
});
}
请大家看一下“提交”这部分,现在的问题是,我要实现文件的上传和一些其他文本内容表单的处理,但是在.ajax提交数据的时候,我是提交到后台的PHP来处理的,现在却无法得到这些表单的值,请问这个如何处理呢?
因为我没有直接写表单的<input type="submit">所以在这不知该如何获取这些表单的值了?
请各位指教,谢谢
作者: jquerypp 发布时间: 2009-07-30
$.ajax({
type: "POST",
url: "/file/index/add",
dataType: "json",
success:function(){
alert("添加成功!");
},
error:function(){
alert("添加失败!");
}
});
看一下这里,这里data部分没有数据,理论上ajax提交的时候应该这样:
$.ajax({
type: "POST",
url: "/file/index/add",
dataType: "json",
data:"xxx"
success:function(){
alert("添加成功!");
},
error:function(){
alert("添加失败!");
}
});
这时,后台可以通过post取得参数值
不过你这里还有文件上传,用ajax不太方便
type: "POST",
url: "/file/index/add",
dataType: "json",
success:function(){
alert("添加成功!");
},
error:function(){
alert("添加失败!");
}
});
看一下这里,这里data部分没有数据,理论上ajax提交的时候应该这样:
$.ajax({
type: "POST",
url: "/file/index/add",
dataType: "json",
data:"xxx"
success:function(){
alert("添加成功!");
},
error:function(){
alert("添加失败!");
}
});
这时,后台可以通过post取得参数值
不过你这里还有文件上传,用ajax不太方便
作者: uord 发布时间: 2009-08-02
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28