XML : PHP file is not working on 000webhost

HTML file

  <!DOCTYPE html>      <html>      <body>      <p id="demo"></p>      <script       <script>      var xml=new XMLHttpRequest();  var url="department.php";  var data=document.getElementById("demo");  xml.open("GET", url, true);  xml.send();      xml.onreadystatechange=function(){  if(xml.readyState == 4 && xml.status==200){  var file=JSON.parse(xml.responseText);  myFunction(file);  }  };  data.innerHTML="Fetching Data..........";    function myFunction(array){  var i=0;  var print="";    for(i=0;i<array.length;i++){    print+=array[i].ID;    }  data.innerHTML=print;  }  </script>  <script></script>  </body>  </html>    

JSON file

  [  {"Name":"Arman",    "ID":"1312038"  },  {"Name":"Khalid",    "ID":"1312024"  },    {"Name":"Robiul",    "ID":"1312025"  }      ]    

PHP File

//

  <?php         header('content-Type:application/json');       $json_data=file_get_content("student.json");      echo $json_data;      ?>    

//

i put all this file in public_html directory.But when i run the department.html,the JSON file is not responding.public_html folder.so why this is not working.Is there any configuration for PHP in 000webhost.or i have done some syntax error?

No comments:

Post a Comment