简体   繁体   中英

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.

I'm using 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. I test on Firefox with firebug and everything is ok, the script works and everything is loaded on the div "content".

But, for some reason, when i try this code on IE8, it doesn't work with PHP files. When i click on a PHP file (something like nota.php?nota=12345 ) the div content just disappears. But if i click on an html link (like test.html ) it works fine.

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...

You need more details on the error other than "just disapears". Try loading IE Developer Toolbar. http://www.microsoft.com/download/en/details.aspx?id=18359

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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