另一种形式提交问题 [英] another Form submit question

查看:104
本文介绍了另一种形式提交问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个形式的onsubmit调用一个ajaxFunction()...的ajaxfunction调用一个PHP函数,它从一个MySQL数据库返回的结果......

I have a form that onsubmit calls an ajaxFunction()... The ajaxfunction calls a php function which returns results from a mysql db...

问题是后退按钮......我希望用户能够搜索,然后再搜索,然后使用后退按钮返回到previous搜索,但是这不会工作......记住,形成并没有真正提交,它会调用ajaxfunction ...

Problem is the back button... I want users to be able to search and then search again and then use the back button to get back to the previous search, but this wont work... Remember, the form doesnt really submit, it calls an ajaxfunction...

我必须使窗体,以使用后退按钮提交?

Do I have to make the form submit in order to use the back button?

BTW我已经尝试提交表单,但页面只是被刷新,ajaxfunction犯规被调用,而导致没有mysql的结果,因为PHP文件从未被称为!

BTW I have tried submitting the form, but the page just gets refreshed and the ajaxfunction doesnt get called and that leads to no mysql results because the php file never got called!!!

感谢所有帮助家伙...让我知道如果你需要更多的输入...

Thanks for all help guys... and let me know if you need more input...

推荐答案

我觉得有用户点击返回按钮pretty的太多失败的AJAX启用表单的利益。

I think that having the users hit the "back" button pretty much defeats the benefit of an ajax-enabled form.

你打电话给你的AJAX功能权限之前,清除DIV的innerHTML属性,让你开始用干净的石板。或者允许用户控制它,所提供的功能中的一个按钮。

Right before you call your ajax function, clear the innerHTML attribute of the div so that you start with a clean slate. Or to allow the users to control it, provide the functionality in a button.

document.getElementById("divid").innerHTML = "";

或jQuery的:

or jQuery:

$("#divid").html("");

编辑/更新:我不能打该网站出于某种原因,但他们可能使用一些jQuery或JavaScript赶上的卸载页面事件。 SO使用这样的事情。您可以使用该事件来调用我上面提到的东西:

EDIT/UPDATE: I cannot hit the site for some reason, but they are probably using some jQuery or Javascript to catch the unload event of the page. SO uses something like this. You could use that event to call the stuff I mentioned above:

$(window).unload(function() { 
    $("#divid").html(""); 
});

这篇关于另一种形式提交问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆