简体   繁体   English

IE中出现奇怪的jQuery错误:对方法或属性访问的意外调用

[英]Strange jQuery error in IE: Unexpected call to method or property access

Like allways, in Firefox, Chrome, Safari and Opera everything works without a problem. 像所有人一样,在Firefox,Chrome,Safari和Opera中,一切都可以顺利运行。 But IE... This is another story :) 但IE ......这是另一个故事:)

Here is my full code: http://pastebin.com/ZdzzFayJ 这是我的完整代码: http//pastebin.com/ZdzzFayJ

At least one thing good in IE, come to me with the following error: 在IE中至少有一件好事,带着以下错误来找我:

SCRIPT65535: Unexpected call to method or property access. 
jquery.min.js, line 3 character 29586

What is wrong? 怎么了? I can't find a bug :( 我找不到一个bug :(


UPDATE UPDATE

I cleaned up my code, javascript functions are now called as a jQuery plugin. 我清理了我的代码,javascript函数现在称为jQuery插件。 I am still getting an error, but now I know where. 我仍然收到错误,但现在我知道在哪里。

In my code I put a comment IE ERROR next to the code where IE alert the error message. 在我的代码中,我在IE警告错误消息的代码旁边放置了IE ERROR注释。

PLUGINS: http://pastebin.com/6Dnd1qtd 插件: http//pastebin.com/6Dnd1qtd

jQuery : http://pastebin.com/wiHALjZx jQuery: http//pastebin.com/wiHALjZx

I have no idea why IE breaks there.. Any solutions? 我不知道为什么IE打破那里..任何解决方案?


Regards, Mario 此致,马里奥

For me the problem was the following: 对我来说问题是:

i use a lib where is applied on all environment. 我使用lib应用于所有环境。

my_lib.js my_lib.js

jQuery.ajax({
        data : jQuery('form').serialize(),
        url : '/'+action[1]+'/post_form',
        type : 'POST',
        dataType: 'json',
        success: function(data){
            $('#my_name_id').find('option').remove().end().append(data.select_options);

});

Json returns: Json回归:

select_options  "<option></option>"

Everything is fine! 一切都好! BUT, in one form #my_name_id is not a select, is a hidden field, it's a pre-selected value and disabled attribute for the user. 但是,在一种形式中,#my_name_id不是选择,是隐藏字段,它是用户的预选值和禁用属性。

That's why jquery on IE8 retrieves me the error. 这就是IE8上的jquery检索错误的原因。

The solution was: 解决方案是:

my_lib.js my_lib.js

jQuery.ajax({
        data : jQuery('form').serialize(),
        url : '/'+action[1]+'/post_form',
        type : 'POST',
        dataType: 'json',
        success: function(data){
          if( $('#my_name_id').is('select') ) {
             $('#my_name_id').find('option').remove().end().append(data.select_options);
          }
});

Hope it helps somebody! 希望它能帮助别人!

You appear to be missing a semi-colon in your get_data function after echo_data(data) . echo_data(data)之后,您的get_data函数中似乎缺少分号。

request.done(function(data) {
    if (data) echo_data(data) _loading.hide();
    _ads_listing.unmask();
});

I solved the problem in the following way: 我用以下方式解决了这个问题:

  • Clean up my code ( JSHint was very helpful! ) 清理我的代码( JSHint非常有帮助!)
  • Before anything I included "//html5shiv.googlecode.com/svn/trunk/html5.js" to IE recognize that I am using HTML5 tags such as section, header,... 之前我把"//html5shiv.googlecode.com/svn/trunk/html5.js"包含在IE中,认识到我正在使用HTML5标签,例如section,header,...
  • In jQuery plugin I fill element with html content. 在jQuery插件中,我用html内容填充元素。 Instead of using $(defaultOpts.data_container).html("HTML CONTENT") I use defaultOpts.data_container.html("HTML CONTENT") . 我使用defaultOpts.data_container.html("HTML CONTENT")而不是使用$(defaultOpts.data_container).html("HTML CONTENT") defaultOpts.data_container.html("HTML CONTENT") So I send object element $(#ID) in parameter to plugin instead of sending just element ID "#ID" . 所以我将参数中的对象元素$(#ID)发送到插件而不是仅发送元素ID "#ID"

Now, everything working OK. 现在,一切正常。 Thank you all for your support and effort. 谢谢大家的支持和努力。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM