Jump to content

Single Refresh


canadabeeau

Recommended Posts

Ah, I remember the mac thingy. Your problem there was you where setting a php session variable via an ajax call and expecting it to refresh the data in the page automatically.

 

As I said in that thread, you need to print your response using javascript to have it actually update the current page. If you read a little bit about ajax and how it works I'm sure you would have a better understanding.

Link to comment
https://forums.phpfreaks.com/topic/185752-single-refresh/#findComment-980835
Share on other sites

I'll post a simple example that illustrates how to update the content of a div using jQuery and Ajax. From there I should expect that you'll do some investigating of your own so you don't have to keep asking these questions.

 

index.php

<html>
    <head>
        <title></title>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
        <script>
            $(document).ready(function() {
                $.ajax({
                    type: "POST",
                    url: "process.php",
                    dataType: "html",
                    success: function(d) {
                        $('#content').html(d);
                    }
                });
            });
        </script>
    </head>
    <body>
        <div id="content">
          <p>This is the initial content.<p>
        <div>
    </body>
</html>

 

process.php

<?php echo "<p>This is ajax requested content</p>"; ?>

 

Not tested.

Link to comment
https://forums.phpfreaks.com/topic/185752-single-refresh/#findComment-980843
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.