InvalidAccessError Internet Explorer

0

I have the following Ajax, for the creation of a credit card, the script works perfectly in chrome but in IE it does not, it throws me an error InvalidAccessError , the site is on https.

$('.js-payment-form').on('submit', function () {
    $('.js-payment-form-btn').prop('disabled', true);

    var valid = false;
    var key = $(this).data('public-key');

    $.ajax({
        url: $(this).data('api-url'),
        method: 'POST',
        data: JSON.stringify({
            primaryAccountNumber: $('#id_number').val(),
            expirationMonth: $('#id_expiration_month').val(),
            expirationYear: $('#id_expiration_year').val(),
            cvc: $('#id_cvv').val(),
            cardHolderName: $(this).data('user-name').substring(0, 25)
        }),
        dataType: 'json',
        contentType: 'application/json',
        cache: false,
        username: key,
        headers: {'Authorization': "Basic " + btoa(key + ':')}
    }).done(function(response) {
        $('#id_token').val(response.token);
        valid = true;
    }).fail(function(response) {
        console.log(response);
        alert('Tarjeta no valida, por favor intenta con una diferente.');
        $('.js-payment-form-btn').removeAttr('disabled');
    });

    return valid;
});

Does anyone have any idea why this happens?

    
asked by Felipe Zuluaga 10.04.2017 в 23:19
source

1 answer

0

It is possible that IE does not interpret your code well. If you use the version lower than 8.0 of IE, JSON.stringify() will not work for you? This part does not seem to be working:

JSON.stringify({
            primaryAccountNumber: $('#id_number').val(),
            expirationMonth: $('#id_expiration_month').val(),
            expirationYear: $('#id_expiration_year').val(),
            cvc: $('#id_cvv').val(),
            cardHolderName: $(this).data('user-name').substring(0, 25)

Check the following link so that you understand more about JSON.stringify and see if you have omitted something that you have not published in the question.

What you need to know about JSON.stringify ()

    
answered by 11.04.2017 в 06:12