Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am getting a "
caught TypeError: Illegal invocation
" in the console everytime I click to submit a form.
I need the data to be passed to the backend to be handled but this error is blocking it.

What could be causing this error and how can I fix this?

Thank you.

What I have tried:

I tried adding processData: false property in the ajax which helps avoid this error. But this is not the fix that I am looking for since no data is being sent to the backend this way.
The following is the js function and where the error is being triggered:

submitEdit: function () {
        var $modal = $('#TransactionEdit')
        $.ajax({
         method: "POST",
         url: $modal.find('#url').data("url"),
         data: {
             Id: $modal.find('#TransactionRow_Id').val(),
             StatId: $modal.find('#TransactionRow_EntryStatus option:selected').val(),
                        
             PaymentDay:$modal.find('#TransactionRow_PaymentDate').val(),
                        
             DocumentDate:$modal.find('#TransactionRow_DocumentDate').val(),
              Amount: $modal.find('#TransactionRow_Amount').val(),
                        
             AmountLCY:$modal.find('#TransactionRow_AmountLCY').val(),
             Tax: $modal.find('#TransactionRow_TaxID option:selected').val(),
             RateType: $modal.find('#TransactionRow_RateType option:selected').val(),
                        
           DocumentNumber:$modal.find('#TransactionRow_Reference').val(),
                        
           Description:$modal.find('#TransactionRow_Description').val(),
                        
         BillingText:$modal.find('#TransactionRow_PaymentDescription').val(),
                        
         SpecialGLIndicatorId:$modal.find('#TransactionRow_SpecialGLIndicatorId option:selected').val(),
          PaymentTermId: $modal.find('#PaymentTermId option:selected').val(),
          PostKeyId: $modal.find('#PostKeyId option:selected').val(),
          TimeStamp: $modal.find('#TimeSpan input:selected').map(function (i, e) { return $(e).attr('data-date'); })
                    },
                    error: function () {
                        alert("Error");
                    }
                }).done(function () {
                    $modal.modal("hide");
                    $modal.html('');
                });
            }
Posted
Updated 13-Apr-23 6:34am
v2

1 solution

It would appear that one or more of your .find calls isn't returning what you think it is.

You're going to have to go through each and every one of those calls and, in the browser console, execute those lines yourself to find out which one are not working as you expect. Executing a .val() or .map() on something that doesn't exist isn't going to work. You're code is assuming every one of these calls succeeds and that's just not the case.

Nobody can do that for you. You're going to have to do this yourself.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900