How do I add PHP code/file to HTML(.html) files?

后端 未结 12 2110
栀梦
栀梦 2020-11-21 22:05

I can\'t use PHP in my HTML pages. For example, index.html. I\'ve tried using both:

 

and



        
12条回答
  •  眼角桃花
    2020-11-21 22:41

    AJAX is also a possibility. Effectively you would want data from the php page. Once you have the data you can format in anyway in javascript and display.

    var xmlhttp = new XMLHttpRequest();
    var url = "risingStars.php";
    
    xmlhttp.onreadystatechange = function () {
        if (this.readyState == 4 && this.status == 200) {
            getDbData(this.responseText);
        }
    }
    xmlhttp.open("GET", url, true);
    xmlhttp.send();
    
    
    function getDbData(response) {
    
    //do whatever you want with respone
    }
    

提交回复
热议问题