Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php refresh page without reloading

window.addEventListener('load', function()
{
    var xhr = null;

    getXmlHttpRequestObject = function()
    {
        if(!xhr)
        {               
            // Create a new XMLHttpRequest object 
            xhr = new XMLHttpRequest();
        }
        return xhr;
    };

    updateLiveData = function()
    {
        var now = new Date();
        // Date string is appended as a query with live data 
        // for not to use the cached version 
        var url = 'livefeed.txt?' + now.getTime();
        xhr = getXmlHttpRequestObject();
        xhr.onreadystatechange = evenHandler;
        // asynchronous requests
        xhr.open("GET", url, true);
        // Send the request over the network
        xhr.send(null);
    };

    updateLiveData();

    function evenHandler()
    {
        // Check response is ready or not
        if(xhr.readyState == 4 && xhr.status == 200)
        {
            dataDiv = document.getElementById('liveData');
            // Set current data text
            dataDiv.innerHTML = xhr.responseText;
            // Update the live data every 1 sec
            setTimeout(updateLiveData(), 1000);
        }
    }
});
Comment

how to refresh a php variable without reloading page

function data() {
        var ret = [];
        ret.push({
          y: 'Today',
          a: <?php echo $data; ?>
        });
      return ret;
    }

var graph = Morris.Bar({
        element: 'graph',
        data: data(),
        xkey: 'y',
        ykeys: ['a'],
        labels: ['random label']
    });

function update() {
      graph.setData(data());
    }

setInterval(update, 60000);
Comment

PREVIOUS NEXT
Code Example
Php :: php isset and test 
Php :: php artisan insert user in database with tinker 
Php :: To Search Specific Post Type 
Php :: php git pull webhook 
Php :: null safe operator in php 
Php :: bu7scador con laravel 
Php :: net::ERR_CONNECTION_REFUSED php 
Php :: vault create/enable secret engine 
Php :: get pivot id laravel 
Php :: array_key_first not works 
Php :: JsonResource::withoutWrapping 
Php :: IlluminateDatabaseQueryException SQLSTATE[HY000]: General error: 3780 Referencing column 
Php :: PHP soundex — Calculate the soundex key of a string 
Php :: cakephp 3 get app url 
Php :: Supprimer automatiquement les mots courts des URL pour un meilleur SEO dans WordPress 
Php :: php mysql submit form 
Php :: hide extension 
Php :: get product by author id 
Php :: This behaviour is (currently) not supported by Doctrine 2 
Php :: Stopping On First Validation Failure 
Php :: why php $_session in not working in react js 
Php :: laravel rename file if exists 
Php :: change php variable value in javascript 
Php :: Laravel image validation just reloads page and does nothing 
Php :: FT_USER 
Php :: search a file name and open that file phpstrom 
Php :: How to create custom php.ini file in CPanel? 
Php :: how to check null and empty array in laravel 8 
Php :: php code for adding dara 
Php :: php get docblock with reflection 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =