【发布时间】:2015-08-11 04:54:41
【问题描述】:
我希望在一个模板 (register.html) 中将下面列出的表单的结果加载到单独的 html 文件 (index.html) 中的内容标记中。目标是让表单提交加载到 index.html 的中心。但是现在,它正在加载一个单独的页面,从而将用户从 index.html 中重定向。任何精通javascript的人都可以提供解决方案吗?非常感谢!
要在 index.html 中加载内容的位置:
<content class="loadContent">
</content>
register.html 表单:
<div class="registration_form">
{% block content %}
<form name="registerform" id="registerform" action="/register_temp/" method="post">{% csrf_token %}
<ul style="position:relative; top:20px;">
<li id="username_registration"><p>Username:</p>{{ form.username }}</li>
<li id="email_registration" class=""><p>Email:</p>{{ form.email}}</li>
<li id="password1_registration" class=""><p>Password:</p>{{ form.password1 }}</li>
<li id="password2_registration" class=""><p>Password confirmation:</p
{{ form.password2 }}</li>
</ul>
<input name="registerform" id="registerform" class="registration_button" type="submit" value="Register" style="position:relative; left:55px;" onclick="userform();" />
</form>
{% endblock %}
</div>
register.html 中的 javascript:
<script>
function userform() {
document.getElementById('registerform').submit();
}
</script>
我已经能够使用此代码在索引中心加载其他链接(但还没有找到表单提交结果的解决方案):(注意:“飞溅”是脚本中引用的是包含 register.html 正文中所有内容的 div id。
<script>
$(function(){
$('').on('click', function( e ){
});
var wrap = $('content');
$('#splash a').on('click', function( e ) {
var href = $(this).attr('href');
wrap.load( href + '' )
.hide().delay(100).fadeIn(500);
e.preventDefault();
});
});
</script>
【问题讨论】:
标签: javascript html django forms