Ajax acces to file on the web


#1

Hello, found this Ajax example below
"Getting Data from Another Site" in Ajax made Simple
It is using also a php part.

Can I use this to read the file from the url “http://www.celestrak.com/NORAD/elements/stations.txt”?
Should I make modifications to the text?
Where to put this php part?

Thanks for any help.

Jan (NL)

Function btnGetFile_onclick()
req=Ajax(“ajaxGetURL.php/?urlToGet=” & encodeURIComponent(txtURL.value))
If req.status=200 Then 'success
htmResponse.innerHTML=req.responseText
Else 'failure
htmResponse.innerHTML=req.err
End If
htmResponse.refresh()
End Function

<?php $ch = curl_init($_GET['urlToGet']); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $data = curl_exec($ch); curl_close($ch); echo $data ?>

#2

The php part needs to be installed on your server. Your server needs to be configured to support PHP.

Have you checked if celestrak has an API? If it does, it would be much easier!