AJAX JQuery не работает, т.е. - PullRequest
       18

AJAX JQuery не работает, т.е.

0 голосов
/ 25 февраля 2011

Привет, ребята.Я использую js / ajax скрипт, который не работает с Internet Explorer.Firefox - это нормально.

Кстати, тег head, я использую это:

$(document).ready(function () {

    //Check if url hash value exists (for bookmark)
    $.history.init(pageload);   

    //highlight the selected link
    $('a[href=' + document.location.hash + ']').addClass('selected');

    //Seearch for link with REL set to ajax
    $('a[rel=ajax]').click(function () {

        //grab the full url
        var hash = this.href;

        //remove the # value
        hash = hash.replace(/^.*#/, '');

        //for back button
        $.history.load(hash);   

        //clear the selected class and add the class class to the selected link
        $('a[rel=ajax]').removeClass('selected');
        $(this).addClass('selected');

        //hide the content and show the progress bar
        $('#content').hide();
        $('#loading').show();

        //run the ajax
        getPage();

        //cancel the anchor tag behaviour
        return false;
    }); 
});


function pageload(hash) {
    //if hash value exists, run the ajax
    if (hash) getPage();    
}

function getPage() {

    //generate the parameter for the php script
    var data = 'page=' + encodeURIComponent(document.location.hash);
    $.ajax({
        url: "http://pathfofolder/js/loader.php",   
        type: "GET",        
        data: data,     
        cache: false,
        success: function (html) {  

            //hide the progress bar
            $('#loading').hide();   

            //add the content retrieved from ajax and put it in the #content div
            $('#content').html(html);

            //display the body with fadeIn transition
            $('#content').fadeIn('slow');       
        }       
    });
}

Файл loader.php содержит php-код для получения страниц, например:

switch($_GET['page'])  {
    case '#link1' : $page = 'contenthere'; break;
} 
echo $page;

Итак, что касается ссылок, я использую Ссылку 1 для загрузки контента в контент div.

Скрипт хорошо работает с Firefox, но с Internet Explorer не загружает контент.Может ли кто-нибудь помочь мне исправить это?

Это не входит в функцию успеха в IE, и я тоже не получаю html-ошибку от IE.

С наилучшими пожеланиями.

1 Ответ

0 голосов
/ 25 февраля 2011

Убедитесь, что ваш HTML это звуки.FF имеет тенденцию автоматически исправлять синтаксис.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...