我正在处理一个表单,据此我可以通过API动态填充表单上的字段。这些字段在 Google chrome中填充得很好,并且在Firefox中可以很好地运行,但是在Firefox中无法运行。
〜请协助
表单布局
<form
id="eazzycheckout-payment-form"
action="https://api-test.*****************" method="POST">
<input type="hidden" id="amount" name="amount" value="">
<input type="hidden" id="orderReference" name="orderReference" value="">
<input type="hidden" id="orderID" name="orderID" value="">
<div class="card-body">
<h5 class="card-title payment"><a href="#" id="mpesa" class="mpesa">Make Payment</a></h5>
</div>
<!--END-->
</form>
包含来自API响应的AJAX代码,通过该代码我可以将响应动态填充到表单字段中
//Fetch input fields via their id
var amount = $('#amount');
var orderID = $('#orderID');
var orderRef = $('#orderReference');
$.ajax({
type: 'POST',
url: 'jengaAPI',
data: JSON.stringify(type),
contentType: 'application/json',
dataType: "json",
success: function(response){
//console.log(response);
//Fetch from response
//Amount
amount.val(response.amount);
orderID.val(response.payment_reference);
orderRef.val(response.payment_reference);
//console.log(amount.val());
//console.log(orderRef.val());
$('#eazzycheckout-payment-form').submit();
},
failure: function(errMsg) {
//alert('Pleas');
}
});