jQuery.submit()-重新设计使用框架/集合的网站
我正在重新设计一个最初写在90年代的网站:(并且可以看到它使用的框架/框架集) 有许多页面允许用户输入客户、产品、订单详细信息并执行提交操作。在提交时,表单将发送给第三方,并生成参考代码并显示给用户 由于该站点是使用框架集开发的,因此发送单个框架时,页眉、导航和页脚保持不变,就像应用程序中出现的生成代码(由第三方创建)一样 当前html的示例:jQuery.submit()-重新设计使用框架/集合的网站,jquery,html,ajax,forms,form-submit,Jquery,Html,Ajax,Forms,Form Submit,我正在重新设计一个最初写在90年代的网站:(并且可以看到它使用的框架/框架集) 有许多页面允许用户输入客户、产品、订单详细信息并执行提交操作。在提交时,表单将发送给第三方,并生成参考代码并显示给用户 由于该站点是使用框架集开发的,因此发送单个框架时,页眉、导航和页脚保持不变,就像应用程序中出现的生成代码(由第三方创建)一样 当前html的示例: <form method="post" name="ReqForm" action="https://3rdparty.com/cgi-bin/3
<form method="post" name="ReqForm" action="https://3rdparty.com/cgi-bin/3rdparty.cfg/php/enduser/custoption.php">
已成功提交上述表格
我的新html:
<form method="post" id="openAccount" name="ReqForm">
我的新代码成功提交表单并生成代码,但是(如a href),应用程序会转到第三方站点并显示参考号
如何捕获表单提交的详细信息(例如uniq ref),并在当前页面/站点中显示
我应该隐藏一个新表单吗
谢谢
更新以下Kevins评论:
在我的表单的HTML中,我有一个按钮:
<button type="button" class="one-sixth submitForm">Submit Details</button>
更新是否有效:
if (isValid) {
alert('1');
$("#openAccount").submit(function(e){
e.preventDefault();
alert('2');
$.post("https://3rdparty.custhelp.com/cgi-bin/3rdparty.cfg/php/enduser/custoption.php",function(result){
//result should contain the response from 3rd party
//execute success actions here
});
alert('3');
});
}
使用Ajax请求向第三方站点发送请求,而不是提交表单。这将允许您在成功处理程序中捕获第三方响应,而无需完全重新加载页面
$("#openAccount").submit(function(e){
e.preventDefault();
$.post("https://3rdparty.custhelp.com/cgi-bin/3rdparty.cfg/php/enduser/custoption.php",function(result){
//result should contain the response from 3rd party
//execute success actions here
});
});
谢谢,我添加了更多关于如何在单击提交时验证表单的代码。我可以将您建议的代码放在我的if(isValid)中吗?@OamPsy我会将验证检查放在
提交
事件处理程序中。使用它来包装对$的调用。post
我提供了另一个更新,并在代码中放置了“警报”,以查看发生了什么。出于某种原因,我只能看到警报1…2和3从未执行。是的,使用jQuery-1.9.1.min。她e是我的小提琴复制问题:
$(".submitForm").click(function () {
....
....
Field validations...
....
....
if (isValid) {
$("#openAccount").attr("action","https://3rdparty.custhelp.com/cgi-bin/3rdparty.cfg/php/enduser/custoption.php");
$("#openAccount").submit();
}
});
if (isValid) {
alert('1');
$("#openAccount").submit(function(e){
e.preventDefault();
alert('2');
$.post("https://3rdparty.custhelp.com/cgi-bin/3rdparty.cfg/php/enduser/custoption.php",function(result){
//result should contain the response from 3rd party
//execute success actions here
});
alert('3');
});
}
$("#openAccount").submit(function(e){
e.preventDefault();
$.post("https://3rdparty.custhelp.com/cgi-bin/3rdparty.cfg/php/enduser/custoption.php",function(result){
//result should contain the response from 3rd party
//execute success actions here
});
});