让我开始说它看起来很简单,但我发现它非常困难。jQuery - 提交w/form插件后重置表格
香港专业教育学院提出,使用PHP和获取的结果是这样的
search.php?term=alice&submit=Submit
标准的东西搜索脚本..问题是,我用AJAX和PHP的SPI所以我的结果将有动态加载到div中,同时仍然保持散列值,因为不会丢失用户在搜索之前访问过的页面。
jQuery.history.js是我使用的后退按钮的支持,这需要链接到像这样的插件:
<a href="#home">Home Page</a>
这将载入“home.html的”到一个名为pageContent股利。因为据我所知,世界上没有其他方法来调用PHP文件,除非你开发了一个小巧的黑客工具,这是我,
这里是我的JavaScript/jQuery的为我的搜索形式:
<script language="JavaScript">
$(document).ready(function() {
// bind form using ajaxForm
$('#search1').ajaxForm({
// target identifies the element(s) to update with the server response
target: '#pageContent',
// success identifies the function to invoke when the server response
success: function() {
$('#pageContent');
var hash = '#search.php?term='+($('#query').val()+'&submit=Submit').replace(/ /g, '+');
var stripped = hash.replace(/(<([^>]+)>)/ig,"");
update(window.location.hash = stripped);
}
});
});
</script>
继承人的形式:
<form id="search1" action="search.php" method="post">
<input id="query" type="text" name="term" />
<input type="submit" name="submit" value="Submit" />
</form>
我的问题是这样的: 香港专业教育学院试图this.form.reset();
这样:Resetting a multi-stage form with jQuery,却没有一个人工作的。请帮助我,如果你知道这样做的方式..
我不明白这将如何帮助我..我需要的表单插件的行动是在发射onsubmit,防止这将帮助我清除表单后,停止提交我的表单? – Ricki 2011-05-22 16:52:46
哦,我可能会误解..但为什么不试着将inputfeild设置为你想要的值作为resset的结果? – 2011-05-23 05:38:50
这样一个简单的解决方案,我发现这之前没有工作的原因是,我把它放在'update(..);'后面,但这不是必须的,就像'window.location.hash = stripped'一样,仍然可以工作。感谢您的回应 – Ricki 2011-05-23 20:43:06