This is my first post here so thanks in advance for your help.
I have a piece of PHP code for getting an airport METAR and displaying it. The code 'metar.php' is as follows:
<?php
$location = "EGLL";
get_metar($location);
function get_metar($location) {
$fileName = "http://weather.noaa.gov/pub/data/observations/metar/stations/$location.TXT";
$metar = '';
$fileData = @file($fileName) or die('METAR not available');
if ($fileData != false) {
list($i, $date) = each($fileData);
$utc = strtotime(trim($date));
$time = date("D, F jS Y g:i A",$utc);
while (list($i, $line) = each($fileData)) {
$metar .= ' ' . trim($line);
}
$metar = trim(str_replace(' ', ' ', $metar));
}
echo "<div style=\"color: white;\">METAR FOR $location (Issued: $time UTC):<br>$metar</div>";
}
?>
Currently, there are buttons on the frontpage of my website that redirect to website.com/metar.php when the button is clicked. The code is as follows:
<li><button type="submit" style="height: 40px;" class="btn btn-primary" onclick="window.location.href = '/heathrow.php'"/>METAR At London Heathrow</button></li>
I would appreciate it if someone can tell me how to change this code so that the button is replaced by the output of metar.php when it is clicked rather than having to redirect to website.com/metar.php when the button is clicked.
I hope that made sense
Thank you very much again in advance!
<script type="text/javascript" src="./jquery-1.3.2.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $('#container-id-to-load-into').load('metar.php); }); </script>