Hi guys,
I have a problem on parsing an XML using JavaScript.
This is my code
Code:function loadXMLDoc(dname) { var xmlDoc; if (window.XMLHttpRequest) { xmlDoc=new window.XMLHttpRequest(); xmlDoc.open("GET",dname,false); xmlDoc.send(""); return xmlDoc.responseXML; } // IE 5 and IE 6 else if (ActiveXObject("Microsoft.XMLDOM")) { xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async=false; xmlDoc.load(dname); return xmlDoc; } alert("Error loading document"); return null; }
then I load the XML:
my proxy.php looks like:Code:xmlDoc=loadXMLDoc("proxy.php?url=http://www.google.com/ig/api?weather=paris,france&hl=sv&u=c");
PHP Code:<?php
$ch = curl_init();
$timeout = 30;
$userAgent = $_SERVER['HTTP_USER_AGENT'];
$url = $_REQUEST['url'];
$hl = $_REQUEST['hl'];
$fullGoogleWeatherPath = $url . "&hl=" . $hl;
curl_setopt($ch, CURLOPT_URL,$fullGoogleWeatherPath);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
$response = curl_exec($ch);
if (curl_errno($ch)) {
echo curl_error($ch);
} else {
curl_close($ch);
echo $response;
}
?>
my server has CURL and PHP installed and the proxy page seems to work just fine when I render it in the browser, but when I try to parse using JavaScript I don't get the data.
I tried to save locally the XML file without using the proxy and it works, so it is probably related to how the Javascript is loading the proxy XML.
Any clue where I can focus, I have been spending hours around it without any success.
thanks for your help.
Max.


Reply With Quote

Bookmarks