Uncaught TypeError: Illegal invocation

0

I have two input ("inputReservaNumero" and "inputReservaCodigo") and a button ("buttonChangeReservation") inside a smartwizard. What I try to do is take the values of the two inputs when I press the button and make an AJAX call, but I get this error in the browser:

Uncaught TypeError: Illegal invocation
    at a (main.js? [sm]:26054)
    at Y (main.js? [sm]:26041)
    at Y (main.js? [sm]:26035)
    at Y (main.js? [sm]:26035)
    at Function.fe.param (main.js? [sm]:26074)
    at Function.ajax (main.js? [sm]:26664)
    at HTMLButtonElement.<anonymous> (main.js? [sm]:30793)
    at HTMLButtonElement.dispatch (main.js? [sm]:22830)
    at HTMLButtonElement.m.handle (main.js? [sm]:22638)
  

This is the HTML code

<div id="cambiarReserva">
    <h3 class="tituloReserva">Modificar reserva</h3>
    <div class="form-group marginRight">
        <label class="" for="mainReservaNumero">Número de reserva</label>
                              <input type="number" class="form-control" id="inputReservaNumero" name="mainReservaNumero">
    </div>
    <div class="form-group">
        <label class="" for="mainReservaCodigo">Código de reserva</label>
        <input type="number" class="form-control" id="inputReservaCodigo" name="mainReservaCodigo">
    </div>
    <div class="form-group">
        <input type="text" class="modificarId" id="inputMainCambiarReserva">
        <button class="btn-ttc btn" id="buttonCambiarReserva">Comprobar</button>
    </div>
    <div class="alert alert-success">
        Si tienes una reserva realizada y deseas cambiarla, escribe tu número de reserva y el código que te mandamos cuando realizaste la reserva y haz clic en siguiente para verificar tu reserva.<br>
        <strong>¡Aviso!</strong> Puedes cambiar la reserva hasta 24 horas antes del día de la actividad reservada, hasta un máximo de 3 meses posteriores, si deseas más tiempo tiene un coste de 10€.
    </div>
</div>
  

JavaScript code

$(document).ready(function(){
    $('#smartwizard').smartWizard({
        lang: {  // Language variables
            next: 'Siguiente', 
            previous: 'Anterior'
        },
        selected: 0,
        keyNavigation:false,
        theme: 'arrows',
        showStepURLhash: false,
        anchorClickable:true,
        transitionEffect: 'fade',
        toolbarSettings: {
                toolbarPosition: 'bottom', // none, top, bottom, both
                toolbarButtonPosition: 'right', // left, right
                showNextButton: true, // show/hide a Next button
                showPreviousButton: true, // show/hide a Previous button
                toolbarExtraButtons: [
                    $('<button id="buttonFinalizar" disabled></button>').text('Finalizar').addClass('btn btn-finalizar disabled').on('click', function(){ 
                        alert('Finish button click');                            
                    })
                ]
        }
    });
    $("#smartwizard").on("showStep", function(e, anchorObject, stepNumber, stepDirection) {
        $.ajax({
            method: 'POST',
            url: 'controller/mainReservas/mainReservas0.php',
            beforeSend: function(){
            $('#load').show();
            },
            success: function(res){

            $('#load').hide();
            $('#pass1').html(res);
            }
        });

        $('#buttonCambiarReserva').click(function(){
            $inputReservaNumero = $('#inputReservaNumero').val();
            $inputReservaCodigo = $('#inputReservaCodigo').val();

            $.ajax({
                method: 'POST',
                url: 'controller/mainReservas/mainReservasCambiar.php',
                data: {numero_php: inputReservaNumero, codigo_php: inputReservaCodigo},
                success: function(res){

                    if(res == 'error1'){
                        $("#errorChange1").show();
                        $("#inputReservaNumero").focus();
                        $("#inputMainCambiarReserva").val('Wrong');
                    }else if(res == 'error2'){
                        $("#errorChange2").show();
                        $("#inputMainCambiarReserva").val('Wrong');
                    }else if(res == 'exito'){
                        $("#inputMainCambiarReserva").val('Ok');
                    }
                }
            }); 
        });
    }); 
});
    
asked by auremanci 21.01.2018 в 13:16
source

1 answer

-1

It seems that the problem has to do with the way to declare these variables as if it were php:

$inputReservaNumero = $('#inputReservaNumero').val();
$inputReservaCodigo = $('#inputReservaCodigo').val();
    
answered by 21.01.2018 в 15:16