开发者

Jquery .load() not working in IE

开发者 https://www.devze.com 2023-02-12 11:28 出处:网络
I use jquerys .load() function on a webpage. It loads a loader.gif file and then a html document into a specific di开发者_运维问答v. It works in FF, Chrome and Safari but not in IE. I\'ve been searchi

I use jquerys .load() function on a webpage. It loads a loader.gif file and then a html document into a specific di开发者_运维问答v. It works in FF, Chrome and Safari but not in IE. I've been searching the web and stll not found an answer to this so I wonder if you can help me. This is my jquery:

$(document).ready(function() {
    $('.loadCat').click(function(e) {
        var url = $(this).attr("href");     
        $('#target').html('loading...');
        $('#target').load(this.href);
            e.preventDefault();
            return false;   
    });
});

EDIT: This is an example of the html i use:

<a href="page.php" class="loadCat">Link</a>

When you click the link in IE the loading... appears but not the page.php im trying to load.


Try this:

$(function(){
    $('.loadCat').click(function(){
        var
            targetElement = $("#target"),
            url = this.href + "?" + new Date().getTime(); //To prevent IE caching

        targetElement.html('loading...');
        $.get(url, function(data){
            targetElement.html(data);
        });
        return false;
    });
});

Edited...

0

精彩评论

暂无评论...
验证码 换一张
取 消