未捕获的TypeError:非法调用

时间:2013-09-23 15:15:11

标签: jquery ajax

自升级到jquery 1.9.1以来,这个过去工作正常的ajax调用会中断chrome。

错误讯息为:Uncaught TypeError: Illegal invocation

在firefox中,它也会中断,错误消息为:NS_ERROR_XPC_BAD_OP_ON_WN_PROTO: Illegal operation on WrappedNative prototype object

这是代码。所有的函数参数都是预期的类型,所以我对这里发生的事情感到有点困惑。

var my_params = {
    'cache': false,
    'data': {
        url: Obj.url,
        section: Obj.section,
        item: Obj.item,
        historyfile: LabHistory.dataFile
    },
    'dataType': 'html',
    'timeout': 3000,
    'url': LabHistory.urlWrite + '?historyfile=' + LabHistory.dataFile
};
/* PROBLEM HAPPENS HERE, AT THE AJAX() CALL. ARGUMENTS ARE
cache=false
    data= {url : 'http://client.dev/projects/project-name/' , section:'projects'
item:'project-name' }
dataType=html
timeout=3000
url=_www/_application/history.write.php 
*/
$.ajax(my_params).done(function()
{
    $.log('history.refresh.write data worked.');
    refreshHistory();
}).fail(function()
{
    $.log('history.refresh.write data failed');
});

修改 这是log()函数。

jQuery.log = function(message)
{
    var mymessage = '';
    if (typeof message === 'array' || typeof message === 'object')
    {
        for (var prop in message)
        {
            if (typeof prop !== 'function')
            {
                mymessage += "\n"+ prop + '=' + message[prop];
            }
        }
    }
    else
    {
        mymessage = message;
    }
    if (window.console)
    {
      window.console.log(mymessage);
    }
};

0 个答案:

没有答案