Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Aug 2006
    Posts
    50
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Refresh instead of replace?

    Hi guys,

    I've just read this short tutorial about Ajax : http://rajshekhar.net/blog/archives/...-Tutorial.html
    I understand how easy it is to replace the content of a div by something else.

    But how am I suppposed to do if, by the same Ajax technique, I just want to refresh a div whose content is supposed to change in accordance to the $_POST variable like in the example below?

    As you can see, I'm trying to keep the HTML/PHP code structure as linear as possible to make it less confusing.

    Code:
    <?php
    
    echo"
    
    ... some HTML ...
    
        <div id=\"update_zone\">
        
        ";
        
            if ($_POST["action"] == 1) {
            
            echo"
            page 1
            ";
            
            } else if ($_POST["action"] == 2) {
            
            echo"
            page 2
            ";    
            
            } else {
            
            }
        
        echo"
        
        </div>
    
    ... some HTML ...
    
    ";
    
    ?>
    Thanks a lot to anyone who will help

  • #2
    New Coder
    Join Date
    Aug 2006
    Posts
    50
    Thanks
    4
    Thanked 0 Times in 0 Posts
    I'm starting to think that my question isn't clear enough.
    Do you guys actually understand what I'm trying to do?

    PS : I don't need someone to write the JS code. I simply need to know where to look.

    Thanks!

  • #3
    Regular Coder ohgod's Avatar
    Join Date
    Jun 2008
    Location
    Ohio
    Posts
    579
    Thanks
    6
    Thanked 69 Times in 69 Posts
    no, it isn't totally clear what you're trying to accompish. if you're trying to replace certain sections of the page conditionally then pass the function that does the call an argument so it knows which one you want. or, set up a switch in the function so it will replace the contents of x based on $_POST['y'].


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •