0

I am trying to get a response from an AJAX call using the code below. However, the AJAX part doesn't seem to be firing.

Any idea what is missing?

$(function() {
    $('#applyVoucher').on('click', function(e) {
        $(this).fadeTo("fast", .5).removeAttr("href"); 
        $(this).html('Applying...');

        $.extend({
            xResponse: function(url, data) {
                var theResponse = null;
                $.ajax({
                    url: url,
                    type: 'post',
                    data: data,
                    async: false,
                    dataType: 'json',
                    success: function(json) {
                        theResponse = json;
                    }
                });
                return theResponse;
            }
        });

        var json = $.xResponse('/voucher/json', {voucher_code: $('input[name=_token]').val(), _token: token});

    });
});
V4n1ll4
  • 5,973
  • 14
  • 53
  • 92

0 Answers0