0

我正在尝试使用 ajax 调用内容的网站,主要是因为该网站有一个广播电台,我希望我网站的用户不要因为他们正在阅读其他文章或类似的东西而停止收听广播.

我正在使用 Jquery。

所以...我有这个功能:

$(function(){    

            // Get a reference to the content div (into which we will load content).
            var jContent = $( "#content" );

            // Hook up link click events to load content.
            $( ".enlaceajax" ).live("click", function( objEvent ){
                    var jLink =  $(this) ;

                    // Clear status list.
                    $( "#ajax-status" ).empty();

                    //Obtenemos de donde estan obteniendo el valor del enlace. ya sea que den clic en el combo box o en un enlace normal.

                    var value = jLink.attr("value");
                    var href = jLink.attr("href");
                    alert(href);
                    if(typeof value === 'undefined')
                    {
                    var linkgo = href;  
                    }
                    else {
                    var linkgo = value; 
                    }

                    // Launch AJAX request.
                    $.ajax(
                        {
                            // The link we are accessing.
                            url: linkgo,
                            // The type of request.
                            type: "GET",
                            // The type of data that is getting returned.
                            dataType: "html",

                            success: function( strData ){
                                // Load the content in to the page.


                                jContent.html( strData );
                                $('html, body').animate({ scrollTop: 0 }, 0);
                            }
                        }                           
                        );

                    // Prevent default click.
                    return( false );                    
                }
                );

        }
        );  

我通过外部文件在我的网站上添加代码。文件正确加载,jQuery 也正确加载。我用 firebug 在 Firefox 上进行测试,一切正常,脚本正常工作,所有内容都加载到 div“内容”上。

但是,由于某种原因,当我在 IE8 上尝试此代码时,它不适用于 PHP 文件。当我单击 PHP 文件(类似nota.php?nota=12345)时,div 内容就会消失。但是,如果我单击 html 链接(如test.html),它可以正常工作。

我已经尝试在几个地方寻找,但我没有找到任何解决方案......而且,我是 jquery 上的真正菜鸟......

4

1 回答 1

0

除了“只是消失”之外,您还需要有关错误的更多详细信息。尝试加载 IE 开发者工具栏。 http://www.microsoft.com/download/en/details.aspx?id=18359

于 2012-04-28T08:29:12.613 回答