Logo Questions Linux Laravel Mysql Ubuntu Git Menu

JavaScript innerHTML include php

Why doesn't my code work?

function _(x){
    return document.getElementById(x);

function friends(){
    _("right").innerHTML = '<?php include_once "friendlist.php";?>';


<!--?php include_once "friendlist.php";?-->

How can I fix it?

like image 241
User Avatar asked Mar 17 '23 20:03


2 Answers

you have to do like this

like image 122
Ayyanar G Avatar answered Apr 01 '23 18:04

Ayyanar G

use below code it will work

 <div id="right">
      document.write('<?php echo include_once "include.php";?>');

or i test below code also it will work

     <div id ="right" >


    function friends(){
     var x=document.getElementById("right");
     x.innerHTML = '<?php include_once "include.php";?>';
like image 21
Nishit Maheta Avatar answered Apr 01 '23 20:04

Nishit Maheta