0

Running a php page (PageA) which receives post information from a 3rd party. Code on page determines whats important etc. If this page then needs to dynamically update a div with relevant content on a second page (PageB) (which is viewable by a user on the same domain), how best to use jquery.append to do this ?

Question is what code do I now need on PageB to receive and update DIV dynamically (not written to a DB, only visible during the time the page is on the users screen ?

Thanks for any insights!

PageA is sending information to PageB

data = {'action': 'message', 'status': status, 'date': date}; 

`

$.ajax({
        cache:false,
        type: 'post',
        url: 'PageB.php',
        datatype: 'json',
        data: data,
        success: function(data) {
            console.log("Data Send");
            $('#tester').append(data);
            }
    });

PageB is receiving post:

if(!empty($_POST) && !empty($_POST['action'])) {
        // Call the function which gets and displays the thumbnails
        if ($_POST['action'] == 'message') {
            code?
        }
    }
Hien Nguyen
  • 24,551
  • 7
  • 52
  • 62
  • Possible duplicate of [PHP Pass variable to next page](https://stackoverflow.com/questions/871858/php-pass-variable-to-next-page) – Sean T Jun 21 '19 at 14:37
  • You need to either store the the data in a cookie and have the user request page b again, or put it in session and use ajax long polling on page b – Sean T Jun 21 '19 at 14:38

1 Answers1

0

you can use html() instead of append() for replace content with new content

$('#tester').html(data); 
Abdo-Host
  • 2,470
  • 34
  • 33