I need to get XML data from a website using an API key, and I'm using AJAX and PHP. Here's my AJAX code (btw, the PHP file is inside a FileZilla server):
var xmlHttpObj=null;
var isPostBack=false;
function CreateXmlHttpRequestObject( )
{ 
  if (window.XMLHttpRequest)
  {
    xmlHttpObj=new XMLHttpRequest()
  }
  else if (window.ActiveXObject)
  {
    xmlHttpObj=new ActiveXObject("Microsoft.XMLHTTP")
  }
  return xmlHttpObj;
}
function MakeHTTPCall_Tags()
{     
  var link = "http://phpdev2.dei.isep.ipp.pt/~i110815/recebeXml.php";
  xmlHttpObj = CreateXmlHttpRequestObject();
  xmlHttpObj.open("GET", link, true);
  xmlHttpObj.onreadystatechange = stateHandler_Tags;
  xmlHttpObj.send();
}
function stateHandler_Tags()
{
  if ( xmlHttpObj.readyState == 4 && xmlHttpObj.status == 200)
  {       
      var selectTags = document.getElementById("tag");
      var option;
      var docxml = xmlHttpObj.responseXML;
      var nodelist = docxml.getElementById("name");
      alert(nodelist.length);
  }  
}
Here's the PHP code:
<?php
    header("Access-Control-Allow-Origin: * ");
    // pedido ao last.fm com a função file_gets_contents 
    // a string XML devolvida pelo servidor last.fm fica armazenada na variável $respostaXML 
    $respostaXML= 
    file_get_contents("http://ws.audioscrobbler.com/2.0/?method=tag.getTopTags&api_key=4399e62e9929a254f92f5cde4baf8a16"); 
    // criar um objecto DOMDocument e inicializá-lo com a string XML recebida 
    $newXML= new DOMDocument('1.0', 'ISO-8859-1'); 
    $newXML->loadXML($respostaXML); 
    echo $newXML;
?>
I'm getting this error from the browser console: GET http://phpdev2.dei.isep.ipp.pt/~i110815/recebeXml.php 500 (Internal Server Error) Anybody knows whats wrong?
 
     
    