dstonek
dstonek

Reputation: 975

Refresh an element in Javascript

Thanks to Refresh (reload) a page once using jQuery? answer I could solve an issue. I have a popup window with a checkbox I want to reflect changes from referred main page, almost instantly. It works great in Safari, Firefox, Chrome, Opera but Internet Explorer.

Thank you

function updateDiv(){
       var ord = getCookie('ordinals');
        if(  ord.indexOf("<?=$ordinal?>")==-1 ){
             document.getElementById("chk<?=$ordinal?>").checked=false//no checked
        }
        else {
            document.getElementById("chk<?=$ordinal?>").checked=true//checked
        }
        $('chk<?=$ordinal?>').html(newContent);
    }

    setInterval('updateDiv()', 1000); // that's 1 second
    ......
    ......
    <body onload="updateDiv(); ....

Upvotes: 0

Views: 1541

Answers (1)

Galled
Galled

Reputation: 4206

I think your problem is with:

$('chk<?=$ordinal?>').html(newContent);

Try with this:

var jEl = $('chk<?=$ordinal?>');

jEl.empty();
jEl.append(newContent);

Upvotes: 1

Related Questions