1

I am getting a 404 : 'GET /undefined' error and can not figure out where it is coming from. Have minimum code in JS, HTML, PHP. See http://www.w3wa.com for info.

Javascript:

function getImage() {
 var xhttp = new XMLHttpRequest;
 xhttp.onreadystatechange = function()  {
  if (this.readyState == 4 && this.status == 200 )  {
   console.log(this.responseText);
   document.getElementById('dot').src = this.responseText;
   document.getElementById('dot').alt = 'three bar thingie';
   document.getElementById('dot').style.width  = '100px';
   document.getElementById('dot').style.height = '100px';
  }
 }
 xhttp.open("GET","Parse.php",true);
 xhttp.send();
}

PHP:

<?php
 /*     Parse.php       
 Geesh, testing ONE item
 */
 echo 'Images/3LineMenu.png';
?>

Surf to http://www.w3wa.com and view source if you wish to see html. Tested with Chrome and Firefox on Linux, Chrome on W10.


HTML:

<img id='dot' src='Images/1dot.png' style='width: 1px; height: 1px;' alt='one little dot'>
<script>document.getElementById('dot').src = getImage();</script>
Phil
  • 157,677
  • 23
  • 242
  • 245
thackett
  • 11
  • 3
  • Change `document.getElementById('dot').src = getImage();` to just `getImage()`. Your function doesn't return anything which is the same as returning `undefined`. See where this is going :) – Phil Aug 13 '18 at 01:26
  • That fixed it. Thank-you! – thackett Aug 13 '18 at 01:53

0 Answers0