1

I'm trying to make some JavaScript actions work in Internet Explorer but so far they aren't working.

The script uses the id atrribute to load a page associated to it. For example: id="4" will be used to look up the value of the page getinfo.php?vid=4 and uses the value of this page to change something on the site.

function btcd() {
var id;
$('.btcd').each(function(i) {
    id = $(this).attr('id');
    id = id.replace('v','');
    $(this).load('js/timeleft.php?vid='+id);
});
$('.btp').each(function(i) {
    id = $(this).attr('id');
    id = id.replace('z','');
    $(this).load('js/price.php?vid='+id);
});
$('.button_bied_nu').each(function(i) {
    id = $(this).attr('id');
    id = id.replace('b','');
    $.get('js/you.php?vid='+id, function(data){
        var res = data.split(' ');
        if(res[1] == '1') {
            $('#b'+res[0]).css('background-image','url(images/button_bied_nu_you.png)');
        }else{
            $('#b'+res[0]).css('background-image','url(images/button_bied_nu.png)');
        }
    });

});

var d = new Date();
var n = d.getMilliseconds();
setTimeout("btcd()",(900-n));
}

The HTML part:

<div class="veilingen">
    <div class="box">
        <div class="box_top">
            <h3><span class="btcd" id="v1" style="float:right;margin-right:10px">202:50:09</span>Testveiling</h3>
        </div>
    <div class="box_bg">
        <div class="box_image">
            <img src="images/veilingen/test.png" alt="Afbeelding" />
            <br />
            <div class="veiling_lint">
                <b>&euro;<span class="btp" id="z1">36</span></b>
                <span style="font-size:8pt;">(Elk bod verhoogt de prijs met &euro;1)</span>
            </div>
        </div>
        <a href="#" onclick="bied(1);" class="button_bied_nu" id="b1">BIED NU!</a><br />
        Klik <a href="?vid=1">hier</a> voor meer informatie over deze veiling.
    </div>
    <div class="box_bottom"></div>
</div>

The page itself: http://project.browsertech.nl/001/index.php

7
  • Could you possibly post some of the HTML mark-up? I would first recommend ensuring that all elements have unique IDs. This is the recommended practice, and I have had experiences with jQuery and IE where this has caused problems. Commented Apr 20, 2012 at 9:59
  • Show the markup as well, so people can see the id values. I'm not seeing any obvious errors in the code. (BTW, there's never any need to do $(this).attr('id'); this.id works universally. Similarly, rather than setTimeout('btcd();',(900-n)) you can -- and should, in this case -- use setTimeout(btcd,(900-n)). E.g., pass a function reference, not a string, into setTimeout.) Commented Apr 20, 2012 at 10:00
  • Added the html code as requested, and also fixed the thins T.J. Crowder told me, thanks for those. Commented Apr 20, 2012 at 10:09
  • Are you sure you are getting a successful response for $.load()? Commented Apr 20, 2012 at 10:16
  • Nope, the whole script just doesn't do a thing in IE, but it works fine in FF, Chrome and Opera (haven't tested any others). Commented Apr 20, 2012 at 10:17

1 Answer 1

1

I reckon this is working but caching. Either use a different ajax call or you could drop this whammy code in:

$.ajaxSetup ({
    cache: false
});

Which will stop the load cache (as well as any jQuery ajax call caches)

Sign up to request clarification or add additional context in comments.

1 Comment

Ty, I was halfway through writing a different theory when it clicked! @Seph, glad its working! :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.