How can I refresh a page via jQuery and ensure that there's a connection?

Posted by Steve on Stack Overflow See other posts from Stack Overflow or by Steve
Published on 2010-05-06T21:59:00Z Indexed on 2010/05/06 22:08 UTC
Read the original article Hit count: 151

Filed under:
|

Hi!

I toyed around with .load() and .ajax(), but i didn't get to an end. Here's what I need: Everey minute the function shall check if it can load a certain page. if the connection succeeds, I want the page to be refreshed, if not, nothing shall happen, the script shall retry later.

I'm using the jQueryTimers plugin. this is my code so far:

//reload trigger
$(document).everyTime('60s', 'pagerefresh', reloadPage, 0, true);

//refresh function
function reloadPage() {
    $.ajax({
        url:'index-1.php',
        type:'HEAD',
        success: location.reload(true)
        })
}

I have no idea how to tell jQ what I want. any hint appreciated.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about refresh