使用jQuery和Ajax使用相同的按钮提交PayPal表单和PHP表单
submit both a paypal form and a php form with the same button, using jquery & ajax
我对HTML和PHP非常熟悉,但对jQuery和Ajax非常熟悉。
搜索了一段时间后,就像这里一样:一个表单,一个提交按钮,但两个操作和这里:写入我的数据库并使用相同的表单向PayPal提交表单?,我仍然对必须写入我的 HTML 文件的 eaxact 代码感到困惑。
我想做的是只需单击"提交"按钮,发送一封包含用户输入的数据的电子邮件(通过"保留.php"文件),并将用户发送到PayPal付款页面。
很抱歉再次提出同样的问题,但我结合这里和其他地方提出的不同解决方案所做的每一次尝试都让我一无所获。
这是我简化的HTML代码:
<html>
<head>
<title>Bienvenue Telecom</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<link rel="shortcut icon" type="image/x-icon" href="/images/favicon.ico" />
<!--[if lte IE 8]><script src="css/ie/html5shiv.js"></script><![endif]-->
<script src="js/jquery.min.js"></script>
<script src="js/jquery.scrolly.min.js"></script>
<script src="js/skel.min.js"></script>
<script src="js/init.js"></script>
<noscript>
<link rel="stylesheet" href="css/skel.css" />
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="css/style-desktop.css" />
</noscript>
<!-- Here is the function I tried to make myself to submit the same form both to paypal and to the reserve.php -->
<script>
$(document).ready(function doublesubmit() {
$.ajax({url: "https://www.paypal.com/cgi-bin/webscr", data: ("form").serialize(), type : "POST", success: function(){
$.ajax({url: "reserve.php", data: $("form").serialize(), type : "POST",
}
});
};
return false;
};
</script>
</head>
<!-- Here is the body of my page, with the only form the user has to fill in -->
<body>
<form id="form" target="_blank" method="post">
<input type="hidden" name="business" value="XXXXXXXX">
<!-- many other hidden and visible input values -->
<input type="submit" value="Send request" name="submit" border="0" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynowCC_LG.gif" alt="PayPal - The safer, easier way to pay online" onclick="doublesubmit();">
</form>
</body>
</html>
不确定为什么要这样做,如果您想在付款确认后向买家发送电子邮件并提供所有必要的信息,我建议您使用 IPN(即时付款通知)。
相关文章:
- 单击禁用表单按钮,然后提交表单
- 如何将POST表单按钮转换为链接
- 按下iframe内部的Youtube订阅表单按钮
- 表单按钮在同一窗口中打开新的URL
- 按下Youtube订阅表单按钮
- 表单按钮上的页面转换
- 禁用表单按钮,除非已填写所有文本输入字段
- 如何查看从 javascript 中的表单按钮提交调用的 php 文件中的回显
- 从“onblur”事件中排除表单按钮,JavaScript
- 触摸启动时显示为灰色的表单按钮
- 如何在表单按钮中使用JavaScript函数
- HTML5表单按钮提交不起作用
- 刮擦:找不到表单按钮
- 保留未保存的表单:按钮提交事件将重置“Changed_Form”状态
- 无法阻止追加在 Jquery UI 对话框上的表单按钮的缺省操作
- iframe 中的表单按钮,单击后,在父窗口中加载
- 在表单按钮css中的文本旁边添加图像
- 使用JavaScript提交特定的表单按钮
- 提交表单按钮在ajax发布后卡住
- 使表单按钮在单击后消失(游戏)