form.submit()到一个特定的DIV
form.submit() to a specific DIV
我想使用Javascript和jQuery提交一个表单到特定的div,但我不知道如何做到这一点。
下面的代码可以工作,将表单提交到当前页面的标题。
var form,
chart = this,
svg = chart.getSVG(chartOptions);
// merge the options
options = merge(chart.options.exporting, options);
// create the form
form = createElement('form', {
method: 'post',
action: options.url
}, {
display: NONE
}, doc.body);
// add the values
each(['filename', 'type', 'width', 'svg'], function(name) {
createElement('input', {
type: HIDDEN,
name: name,
value: {
filename: options.filename || 'chart',
type: options.type,
width: options.width,
svg: svg
}[name]
}, null, form);
});
// submit
form.submit();
// clean up
discardElement(form);
我已经尝试了各种选择,但没有工作。简单来说,我想这样做:
$('#myDiv').form.submit();
或者换句话说,将提交命令发送到名为myDiv
的div。
有谁知道我会怎么做吗?谢谢。
您应该能够使用这里给出的代码:
在JQuery中发布表单并在IE中填充DIV - broken
$.ajax({
url: options.url,
type: 'POST',
cache: false,
data: {
filename: options.filename || 'chart',
type: options.type,
width: options.width,
svg: svg
},
dataType: 'text',
complete: function(xhr, textStatus) {
alert('completed');
},
success: function(data) {
$("#myDiv").html(data);
},
error: function(xhr, textStatus, errorThrown) {
alert('woops');
}
});
$('#myDiv').click (function () {
$("form").submit();
});
相关文章:
- 通过DRAGGABLE将一个DIV移动到另一个DIF下?(CSS,JQuery)
- 限制一个DIV出现在另一个特定大小的DIV中
- 使用jQuery将DIV放在另一个DIV上
- 只翻转一个DIV,而不是所有DIV都属于同一类
- 更改另一个 DIV 之前的 DIV 宽度
- JQuery 将一个 Div 值的百分比添加到另一个值
- jQuery - 在另一个 DIV 中定位特定的 DIV
- 选中复选框时仅重新加载一个DIV
- 动态创建一个DIV容器
- 在悬停时显示一个DIV,在悬停的另一个DIV.使用CSS
- 将DIV内容复制到另一个DIV
- 当调用DIV时,将一个DIV加载到另一个的顶部
- 通过点击隐藏DIV,并通过JavaScript显示另一个DIV
- 同时换掉两个Div,换成另一个Div并保持循环一段固定的秒数
- For循环只打印一个DIV标记.不是8个DIV标签
- 切换一个Div与按钮改变左边距属性
- 使用 javascript 在 DOM 中隐藏 DIV 中的文本,具体取决于另一个 DIV 中的文本
- 如何根据另一个 DIV 内容的可见性显示 DIV 内容
- DIV 滚动到达页脚(另一个 DIV)后停止滚动
- JQuery 滚动到滚动到下一个 DIV