Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.