Change div content with a php file

Discussion in 'PHP' started by Nithya_hiox, Dec 16, 2010.

  1. #1
    Hi,
    I want to change a div content with a php file every 5 seconds.

    I have two php files and I want to change div content with that files alternatively every 5 seconds.

    I tried some code. But it doesn't works. Can anybody please help me?

    function firstCall() {
    $("#divid").load("emails.php");
    setTimeout("secondCall()", 5000);
    }
    function secondCall() {
    $("#divid").load("add.php");
    setTimeout("firstCall()", 5000);
    }
    <body onload="firstCall()">


    Thanks in Advance.
     
    Nithya_hiox, Dec 16, 2010 IP
  2. renlok

    renlok Well-Known Member

    Messages:
    457
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    110
    #2
    this is javascript not php and try

    function firstCall() {
    $("#divid").load("emails.php");
    setTimeout("secondCall", 5000);
    }
    function secondCall() {
    $("#divid").load("add.php");
    setTimeout("firstCall", 5000);
    }
    <body onload="firstCall()">
     
    renlok, Dec 16, 2010 IP
  3. Nithya_hiox

    Nithya_hiox Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi,

    I tried the code as you said. The first php file loads properly but the second php file is not loaded. I don't know what's the problem with the code.
     
    Nithya_hiox, Dec 16, 2010 IP
  4. openbytes

    openbytes Peon

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    you can't do that with php you will need javascript or any other serverside technology
     
    openbytes, Dec 16, 2010 IP
  5. tvoodoo

    tvoodoo Active Member

    Messages:
    239
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    53
    #5
    
    var current = 1;
    function call() {
    if(current % 2 == 0)
    $("#divid").load("add.php");
    else
    $("#divid").load("emails.php");
    
    current++;
    setTimeout("call()", 5000);
    }
    
    <body onload="call()">
    
    HTML:
     
    tvoodoo, Dec 16, 2010 IP
  6. Simple Management

    Simple Management Peon

    Messages:
    39
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I believe you meant to say client-side ?
     
    Simple Management, Dec 17, 2010 IP