I'm new to Javascript, but we all was at sometime. I'm Stuck!
I can get my XMLHTTPRequest response ok from a gov site in xml format (no JSON available). I can't get it to console log or display to my html page. I can only see it in the firefox>developertools>network>response
What am I doing wrong? I want to see it in my console log and get it to my html page.
MY RESPONSE - IN FIREFOX: >developerTools>network>response
<?xml version="1.0" encoding="UTF-8"?>
<response xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:noNamespaceSchemaLocation="http://www.aviationweather.gov/static/adds/schema/metar1_2.xsd">
<request_index>174466304</request_index>
<data_source name="metars" />
<request type="retrieve" />
<errors />
<warnings />
<time_taken_ms>14</time_taken_ms>
<data num_results="6">
<METAR>
<raw_text>KCRX 161655Z AUTO 29010KT 9SM BKN012 OVC017 03/00 A3000 RMK AO2</raw_text>
<station_id>KCRX</station_id>
<observation_time>2020-12-16T16:55:00Z</observation_time>
<latitude>34.92</latitude>
<longitude>-88.6</longitude>
<temp_c>3.0</temp_c>
<dewpoint_c>0.0</dewpoint_c>
<wind_dir_degrees>290</wind_dir_degrees>
<wind_speed_kt>10</wind_speed_kt>
<visibility_statute_mi>9.0</visibility_statute_mi>
<altim_in_hg>30.0</altim_in_hg>
<quality_control_flags>
<auto>TRUE</auto>
<auto_station>TRUE</auto_station>
</quality_control_flags>
<sky_condition sky_cover="BKN" cloud_base_ft_agl="1200" />
<sky_condition sky_cover="OVC" cloud_base_ft_agl="1700" />
<flight_category>MVFR</flight_category>
<metar_type>METAR</metar_type>
<elevation_m>128.0</elevation_m>
</METAR>
</data>
</response>
MY XMLHTTPRequest:
const request = new XMLHttpRequest();
request.open('GET', 'https://www.aviationweather.gov/adds/dataserver_current/httpparam?dataSource=metars&requestType=retrieve&format=xml&stationString=KCRX&hoursBeforeNow=2',);
request.onload = function() {
console.log(request);
};
request.send();
My Console shows:
MY Header: enter image description here