在Mozilla Firefox上通过API填充响应代码时出现问题

时间:2018-12-05 13:21:23

标签: javascript ajax firefox cross-browser

正在使用Laravel应用程序,通过该应用程序,它可以从API提取一些数据并将其发送到外部付款网关iframe。我从后端(在Laravel上构建)通过AJAX获取响应,并在表单上的某些隐藏输入上填充响应。

在Google chrome和Internet Explorer中很好地填充了输入。在firefox中,我必须手动刷新页面,以便可以在表单输入中捕获动态输入。

我想实现一个Js功能,该功能检查用户是否在任何版本的Mozilla firefox浏览器上,它应该执行后台页面刷新(或刷新响应代码),以便可以将其填充在隐藏的输入中。 / p>

请协助?

//Get the fields from the form via their id
var amount = $('#amount');
var orderID = $('#orderID');
var  orderRef = $('#orderReference');

//AJAX code that post data to the backend and get the response
$.ajax({
        type: 'POST',
        url: 'jengaAPI',
        data: JSON.stringify(type),
        contentType: 'application/json',
        dataType: "json",
        success: function(response){

            //Check for any version of Mozilla firefox
            if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1){
              // Do Page refresh
            }

            //Populating the hidden inputs on the form dynamically which is fine on chrome & IE 
            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('error');
        }
    });

0 个答案:

没有答案
相关问题