简体   繁体   English

尝试在我的网站上进行ajax调用。 适用于现代浏览器(IE9,Chrome,FF),但IE8

[英]Trying to make ajax calls on my site. Works on modern browsers (IE9, Chrome, FF) but IE8

I'm trying to make a site with ajax calls for the content, mostly because the site has a radio station and i would like the users of my site don't stop hearing the radio because they're reading other articles or something like that. 我正在尝试用ajax调用该内容的网站,主要是因为该网站有一个广播电台,我希望我站点的用户不要停止收听广播,因为他们正在阅读其他文章或类似内容。

I'm using Jquery. 我正在使用Jquery。

so... i have this function: 所以...我有这个功能:

$(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 );                    
                }
                );

        }
        );  

I add the code on my site via an external file. 我通过外部文件将代码添加到我的网站上。 the file loads correctly and the jQuery too. 文件正确加载,jQuery也正确加载。 I test on Firefox with firebug and everything is ok, the script works and everything is loaded on the div "content". 我在Firefox上使用firebug进行了测试,一切正常,脚本可以正常运行,并且所有内容都已加载到div“内容”上。

But, for some reason, when i try this code on IE8, it doesn't work with PHP files. 但是,由于某种原因,当我在IE8上尝试此代码时,它不适用于PHP文件。 When i click on a PHP file (something like nota.php?nota=12345 ) the div content just disappears. 当我单击一个PHP文件(类似于nota.php?nota=12345 )时,div内容就消失了。 But if i click on an html link (like test.html ) it works fine. 但是,如果我单击html链接(如test.html ),则可以正常工作。

I've tried looking on several places and I just don't find any solution to this... also, I'm a real noob on jquery... 我尝试在几个地方寻找,但是我没有找到任何解决方案……而且,我对jquery确实是个菜鸟。

You need more details on the error other than "just disapears". 除了“只是消失”以外,您还需要更多有关该错误的详细信息。 Try loading IE Developer Toolbar. 尝试加载IE开发者工具栏。 http://www.microsoft.com/download/en/details.aspx?id=18359 http://www.microsoft.com/download/en/details.aspx?id=18359

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

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