我在向付款处理器提交信息的页面上有一个付款按钮,并且在同一页面上有一个表单,其中有一些自定义字段,用于在您提交联系信息时更新联系人信息。Jquery提交表单并将特定值发布到另一个脚本
我使用提交付款按钮的jquery脚本,同时将表单的值提交给updatecontact php脚本。
但它不工作,它不会将值发布到updatecontact php脚本。
请看看下面的代码,看看你是否能发现我做错了什么。
其中代码的网址是:http://ofertasclaras.com/envio.php
我在向付款处理器提交信息的页面上有一个付款按钮,并且在同一页面上有一个表单,其中有一些自定义字段,用于在您提交联系信息时更新联系人信息。Jquery提交表单并将特定值发布到另一个脚本
我使用提交付款按钮的jquery脚本,同时将表单的值提交给updatecontact php脚本。
但它不工作,它不会将值发布到updatecontact php脚本。
请看看下面的代码,看看你是否能发现我做错了什么。
其中代码的网址是:http://ofertasclaras.com/envio.php
您正在尝试创建具有多个提交操作的表单。因为这时你的服务器发布到DineroMail的,而不是访问者的浏览器
卷曲将无法正常工作(除非你真的想你的服务器进行购买?);)
相反,使用jQuery添加一个Ajax请求到表单提交。通过使ajax请求不是异步的,它会在使用“return true”提交给表单的主动作(dineromail)之前完成该请求。
$(document).ready(function() {
$('#dinero-form').submit(function() {
$.ajax({ type: "POST", async: false, url: 'http://ofertasclaras.com/actualizar.php',
data: { email: $('#email').val(),nombrecompleto: $('#nombrecompleto').val(), direccion: $('#direccion').val(), ciudad: $('#ciudad').val(), provincia: $('#provincia').val(), codigopostal: $('#codigopostal').val(), casaodepto: $('#casaodepto').val(), gelypilas: $('#gelypilas').val() }
});
return true;
});
});
真棒解决方案。它的胜利者,谢谢! – sebas
在你的小提琴,启动东西了,不会匹配任何选择:如果这是唯一
$('#dinero-form')
不知道问题,但您可能需要更新form
标签,如下所示:
<form action='https://argentina.dineromail.com/Shop/Shop_Ingreso.asp'
method='post' id='dinero-form'>
我忘了将它添加在小提琴上,但即时通讯使用它在页面上,jsfiddle更新。这不是问题 – sebas
会在你的情况这个逻辑流程工作:
1)捕捉使用AJAX 2)发送您所需要的数据,以您的网址,并在形式 3)返回false表格后当你的页面返回成功,提交表单到支付网关页面
// prime your element with a state that you can check on later
// in thise case 'captured' via the .data() method, set to false (not yet captured by your script)
$('#dinero-form').data('captured',false).submit(function(){
// bind to the submit event of the form and return false by default unless
// captured is true, which means your form has been captured by your page
// and you're happy to pass the form data on to the gateway (be sure this is over ssl on your own server, etc, as necessary for appropriate security)
var $this = $(this), data = $this.serialize(), captured = $this.data('captured');
// if not captured, send to your script
if(false === captured) {
$.post('/url-for-your-data/',data,function(response){
// change this to your url where you want to capture it
// if you are returning json, use something like the below (with your own values)
// to determine if it was successful or not at storing the data you want to capture
if(response.success) {
// if it succeeded, then tell the form it has been captured and then trigger
// the original submit to the form action defined in your form
$this.data('captured',true);
$this.trigger('submit');
} else {
// handle form validation here
}
},'json');
// return false so the form doesn't submit and you can wait for the response
// usually a good idea to show a loading/activity graphic at this point if it's not quick
return false;
} else {
// otherwise it was captured, and you can send to the gateway now
return true;
}
});
** WARNING **:虽然这工作,同时启用JavaScript,你会从第一次提交给你的页面中受益,捕捉到它,并设置任何会话变量然后以某种方式将它发送到您的网关并为该交易提供一个唯一的ID您可以在用户返回到您的网站时将其匹配。 (如果适用的话)。
**警告**:您应该始终通过SSL发送个人信息,因此请确保您有这样的事情解决,并确保您的用户知道他们的数据已保护到您的服务器和他们正在使用的网关:)
你不能在域之间使用ajax来POST,所以这个脚本根本无法在jsFiddle中工作。您实际尝试运行此网页的网址的网址是什么? –
你有没有尝试做你的jQuery函数中的表单提交作为回调? – Smamatti
URL是这一个:http://ofertasclaras.com/envio.php @Smamatti你能告诉我一个例子吗? – sebas