简体   繁体   English

从jQuery + AJAX请求中选择时,IE8返回NULL

[英]IE8 is returning NULL when selecting from jQuery + AJAX request

I have no idea why this is happening. 我不知道为什么会这样。 First off, the code is valid via W3C validator as HTML5 EXCEPT for URL encoding issues (like & should be & amp;) but i don't have control over that and that shouldn't cause this error anyways. 首先,该代码通过W3C验证器对HTML5 EXCEPT有效,可解决URL编码问题(例如&应该是&),但我对此没有控制权,并且无​​论如何也不会导致此错误。

Second, this works in all other browsers. 其次,这适用于所有其他浏览器。

Third, the "data" element you'll see in the JS below returns the HTML from the requested page fine. 第三,您将在下面的JS中看到“ data”元素,可以从请求的页面中很好地返回HTML。

$('.calendarWrap .dayEvents li:not(.prevMonth) a').click(function(e){
            the_url = $(this).attr('href');
            $.get($(this).attr('href'),function(data){
                $('#calendar-bubble').remove();
                $('body').prepend('<div style="display:none;left:'+(e.pageX)+'px;top:'+e.pageY+'px;" id="calendar-bubble">'+$('#main-content',data).html()+'<p class="details"><a href="'+the_url+'">View event details &gt;</a></p></div>').find('#calendar-bubble').fadeIn(150);
                $cb = $('#calendar-bubble');
                if($(window).width()-($cb.outerWidth()+$cb.offset().left) < 0){
                    $cb.css({left:(e.pageX-$cb.outerWidth())+'px'});
                }
                if($(window).height()-($cb.outerHeight()+$cb.offset().top-$(window).scrollTop()) < 0){
                    $cb.css({top:(e.pageY-$cb.outerHeight())+'px'});
                }
            });
            return false;
        });

Lastly, here is the HTML for the requested page: http://pastebin.com/DZE79xiA 最后,这是请求页面的HTML: http : //pastebin.com/DZE79xiA

I'm out of ideas... 我没主意...

Does anyone know of any alternative ways to get the data like this and parse through it and only grab #main-content? 有谁知道获取这种数据并解析并仅获取#main-content的其他方法吗?

Finally, after about a week of fighting this i found out it's because of HTML5 elements. 最终,经过大约一周的努力,我发现这是由于HTML5元素所致。 I ended up having to use: http://jdbartlett.github.com/innershiv/ and all worked after that. 我最终不得不使用: http : //jdbartlett.github.com/innershiv/ ,之后一切都可以使用。

What you've pasted seems to be correct. 您粘贴的内容似乎是正确的。 If I understand your problem right you could try 如果我了解您的问题,可以尝试

var content = $(data).find('#main-content')

instead of 代替

$('#main-content',data)

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

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