开发者

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 am now getting this error "Illegal operation on WrappedNative 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){            
        },
        erro开发者_JAVA技巧r: function(xhr, textStatus, errorThrown) {
            doAlert('An error occurred: '+xhr.responseText);
        },
        complete: complete
    });

}

doAjax('', {});

Anyone have any idea what the problem could be?


The problem is with the line where you are assigning window.location to url. It should be window.location.href.

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

I am not sure about the reasons though. Will update the post once I figure out.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜