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(null); } function stateHandler_Tags() { if ( xmlHttpObj.readyState == 4 && xmlHttpObj.status == 200) { alert("dsadas"); var selectTags = document.getElementById("tag"); var option; var docxml = xmlHttpObj.responseXML; var namesnodelist = docxml.splitgetElementById(",""name"); alert(namesnodelist.length); } } <?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&ap i_key=5bc5d54260065f88eb0e97897aa53a0f"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); // navegar no XML com os métodos que já conhece, mas com uma sintaxe PHP para // aceder a objectos(->) $nodelist=$newXML->getElementsByTagName("name"); $tags=""; for ($i=0;$i<$nodelist->length;$i++) { $tagNode=$nodelist->item($i); $tagValue = $tagNode->nodeValue; $tags.=$tagValue . ","; } // para teste echo $tags; $newXML; ?> The PHP file isn't receivingI'm getting this error from the XML data correctly.browser console: GET http://phpdev2.dei.isep.ipp.pt/~i110815/recebeXml.php 500 (Internal Server Error) Anybody knows whats wrong?