尝试发布到新窗口中,但是新窗口打开了,但是页面空白。
在alignet.js中
//first_step
$('form').submit(function(){ return false; });
$('#submit_first').click(function(){
//remove classes
$('#first_step input').removeClass('error').removeClass('valid');
//ckeck if inputs aren't empty
//var fields = $('#first_step input[type=text]');
var error = 0;
$( ':input[type=text]', '#first_step').each( function () {
if ( this.value.trim() == false ) {
$(this).addClass('error');
error++;
}
});
if(!error) {
//update progress bar
$('#progress_text').html('50% Complete');
$('#progress').css('width','113px');
//slide steps
$('#first_step').slideUp();
dataString = $("#first_step input").serialize();
//alert(dataString);
$.ajax({
type: "POST",
url: "../../wp-content/plugins/oci-alignet/process.php",
data: dataString,
success: function(data) {
var alignet_encrypted = jQuery.parseJSON(data);
$("input[name=XMLREQ]").val(alignet_encrypted.XMLREQ);
$("input[name=SESSIONKEY]").val(alignet_encrypted.SESSIONKEY);
$("input[name=DIGITALSIGN]").val(alignet_encrypted.DIGITALSIGN);
}
},
"json");
$('#second_step').slideDown();
} else return false;
});
生成的PHP
$html = '<!-- #first_step -->
<div id="first_step">
<h1>Informacion General</h1>
<h5>Recuerden que SITENAME no pide numero de tarjeta ni su cuenta Bancario</h5>
<div class="form">
<label for="purchaseCommerceAmount">Valor (USD):</label>
<input type="text" name="purchaseCommerceAmount" id="purchaseCommerceAmount" value="20.00" />
<label for="billingFirstName">Nombre del tarjetahabiente. (como aparece en la tarjeta de crédito):</label>
<input type="text" name="billingFirstName" id="billingFirstName" value="" />
<label for="billingLastName">Apellido del tarjetahabiente. (como aparece en la tarjeta de crédito) :</label>
<input type="text" name="billingLastName" id="billingLastName" value="" />
<label for="billingEMail">Dirección electrónica del tarjetahabiente.:</label>
<input type="text" name="billingEMail" id="billingEMail" value="" />
<label for="billingAddress">Dirección del tarjetahabiente:</label>
<input type="text" name="billingAddress" id="billingAddress" value="" />
<label for="billingZIP">Código Postal del tarjetahabiente:</label>
<input type="text" name="billingZIP" id="billingZIP" value="XX000" />
<label for="billingCity">Nombre de la ciudad del tarjetahabiente:</label>
<input type="text" name="billingCity" id="billingCity" value="" />
<label for="billingState">Nombre del estado del tarjetahabiente:</label>
<input type="text" name="billingState" id="billingState" value="" />
<label for="billingCountry">Código (eg: EC,BR,AR) del país del tarjetahabiente:</label>
<input type="text" name="billingCountry" id="billingCountry" value="EC" />
<label for="billingPhone">Teléfono del tarjetahabiente:</label>
<input type="text" name="billingPhone" id="billingPhone" value="" />
<label for="shippingFirstName">Nombre de la persona que recibirá los bienes:</label>
<input type="text" name="billingFirstName" id="billingFirstName" value="" />
<label for="shippingLastName">Apellido del tarjetahabiente. (como aparece en la tarjeta de crédito) :</label>
<input type="text" name="billingLastName" id="billingLastName" value="" />
<label for="shippingEMail">Email de la persona que recibirá los bienes:</label>
<input type="text" name="shippingEMail" id="shippingEMail" value="" />
<label for="shippingAddress">Dirección de entrega del pedido del tarjetahabiente:</label>
<input type="text" name="shippingAddress" id="shippingAddress" value="" />
</div>
<!-- clearfix -->
<div class="clear">
</div>
<!-- /clearfix -->
<input class="submit" type="submit" name="submit_first" id="submit_first" value="Continuar" />
</div>
<!-- #second_step -->
<form id="second" method="POST" action="https://test2.alignetsac.com/VPOS/MM/transactionStart20.do" target="foo" onSubmit="window.open(\'\', \'foo\', \'width=450,height=300,status=yes,resizable=yes,scrollbars=yes\')">
<div id="second_step">
<h2>DATA COMPILED READY TO SEND</h2>
<div class="form">
<label for="XMLREQ">XMLREQ</label>
<input type="text" name="XMLREQ" id="XMLREQ" value="" />
<label for="DIGITALSIGN">DIGITALSIGN</label>
<input type="text" name="DIGITALSIGN" id="DIGITALSIGN" value="" />
<label for="SESSIONKEY">SESSIONKEY</label>
<input type="text" name="SESSIONKEY" id="SESSIONKEY" value="" />
<lable for"URLVPOS">URLVPOS</label>
<select name="URLVPOS" id="URLVPOS">
<option value="https://test2.alignetsac.com/VPOS/MM/transactionStart20.do">preprod.verifika.com</option>
</select>
</div>
<!-- clearfix --><div class="clear"></div><!-- /clearfix -->
<input class="submit" type="submit" name="submit_second" value="Send" />
<!-- clearfix --><div class="clear"></div><!-- /clearfix -->
</div>
</form>
<div id="progress_bar">
<div id="progress"></div>
<div id="progress_text">0% Complete</div>
</div>';
return $html;
}
https链接可以正常工作。 Vpos数据以表格形式设置。
最佳答案
真正需要使用AJAX / jquery来打开新表单的表单输出。
提交按钮将自动提交表单,因此您只需要编辑它的目标即可:
<form name="input" action="html_form_action.php" method="get" target="_blank">
确保无论ajax部分如何,调用的响应都不为空
关于javascript - 在新窗口中发布会显示空白页(jQuery),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/17509536/