Problem with jquery ajax after upgrade from 1.4.2 to 1.4.4

After upgrading jquery from 1.4.2 to 1.4.4, I get this error "Illegal operation on a ProtopNative Prototype object" when trying to use $ .ajax ()

Here is the simplified code:

function doAjax(url, data, complete) {    
    if (data == null) {
        var data = {};
    }
    if (complete == null) {
        var complete = function(){};
    }

    if (url == '') {
        url = window.location;
    }

    data.ajax = 1;
    $.ajax({
        type: 'POST',
        url: url,
        cache: false,
        data: data,
        dataType: 'script',
        success: function(data, textStatus){            
        },
        error: function(xhr, textStatus, errorThrown) {
            doAlert('An error occurred: '+xhr.responseText);
        },
        complete: complete
    });

}

doAjax('', {});

Can anyone understand what the problem is?

+3
source share
1 answer

The problem is the line where you assign window.location for the URL. This should be window.location.href.

if (url == '') {
 url = window.location.href;
}

However, I am not sure of the reasons. Will update the message after I find out.

+3
source

Source: https://habr.com/ru/post/1785224/


All Articles