问题描述
我的网页上有两种表格 - 一种是将特定信息写入数据库,另一种是让您使用Paypal付款(我拥有的页面用于购买产品)。
现在有两种形式,但我想让它们都能同时提交。也就是说,当你点击PayPal按钮时,它会发布这两个表单。
我可以把它们都放在同一个post方法中吗?或者我该如何解决这个问题?
我想让客户购买一些东西,然后执行PayPal帖子(实际付款),但是页面也写入我自己的数据库与客户的信息。
使用jQuery和/或任何库都可以。
这是我的JS:
以下是我的HTML:
这是我的post.php:
您已经使用jQuery提交PayPal表单:点击(功能(){
$ .post('post .php',$('#myForm')。serialize(),function(){
$ b $('#paypal')。submit();
} );
});
只是在点击#paypalButton之后立即发布其他表单!
$ p $
$('#paypalButton')。click函数(){
$ .post('post.php',$('#myForm')。serialize(),function(){
$('#贝宝')提交();
});
$ .post('mydbprocessingurl.php',$('#myOtherForm')。serialize());
});
I have two forms on my webpage - one that writes certain information to a database, and one that lets you pay using Paypal (the page I have is for buying a product).
Right now, there are the two forms, but I want to make it so that both submit at the same time. That is, when you click the Paypal button, it posts both forms.
Can I put them both in the same post method somehow? Or how can I solve this problem?
I want it so a customer can buy something, and the Paypal post executes (for the actual payment) but the page also writes to my own database with the information of the customer.
I'm fine with using jQuery and/or any libraries.
Here's my JS: http://slexy.org/view/s2u2Jsr2RI
Here's my HTML: http://slexy.org/view/s2NgzHRES4
Here's my post.php: http://slexy.org/view/s208WfbKso
You're already using jQuery to submit the PayPal form:
$('#paypalButton').click(function(){
$.post('post.php', $('#myForm').serialize(), function(){
$('#paypal').submit();
});
});
Just have it post the other form right afterward, after clicking on the #paypalButton!
$('#paypalButton').click(function(){
$.post('post.php', $('#myForm').serialize(), function(){
$('#paypal').submit();
});
$.post('mydbprocessingurl.php', $('#myOtherForm').serialize());
});
这篇关于写入我的数据库并使用相同的表单向PayPal提交表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!