Like I said, the code used to work fine on the desktop (and still does).
I've tried changing the file to an html rather than php, no luck.
I have a feeling it has to do with permissions and that apache2 isn't able to send the client the image. I've done no configuring of apache2, it's standard with ubuntu... maybe this is really the source of error?
The reason I posted it in PHP is because all the JS was working fine until I moved it to the localhost root (/var/www/).
Also, I had the image as "map.jpg" as noted in the comment. I was merely trying "/var/www/map.jpg" to see if that was a problem (but you're absolutly right, that makes 0 sense to a client which has no idea they are in my "/var/www" folder).
I actually figured out the problem with a little bit of messing around and reading.
"map.jpg" permissions were set as:
-rw------- (observed using "ls -l" in terminal)
This means that only I can read and write to the image file, no one in my group or on the computer can do anything but me (excluding root of course).
I modified the permissions on the file to:
using "chmod g+rw map.jpg"
and "chmod a+r map.jpg"
which lets my group read and write and everyone (all) read, respectively.
That solved the problem. Before when I tried to view "localhost/map.jpg" I got a "403 access denied" error. Now I can see the image fine as a client. This was infact not a JS or a PHP problem, but merely a unix file-permission problem.
Thanks for the response again PeejAvery. I'm learning something new about computers every day