Click here to Skip to main content
15,798,508 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')
         method: "POST",
         url: $modal.find('#url').data("url"),
         data: {
             Id: $modal.find('#TransactionRow_Id').val(),
             StatId: $modal.find('#TransactionRow_EntryStatus option:selected').val(),
              Amount: $modal.find('#TransactionRow_Amount').val(),
             Tax: $modal.find('#TransactionRow_TaxID option:selected').val(),
             RateType: $modal.find('#TransactionRow_RateType option:selected').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 () {
                }).done(function () {
Updated 13-Apr-23 7:34am

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