0

I created a PHP file, which give back an image location. for example: https://www.example.com/api/example.php Its give back this: https://www.example.com/image1.png

Its okey. But I need to read the example.php and GET the image location (so the https:// www dot example dot com/image1.png) and display on my site with Javascript.

var wheelImageName   = "url/image1.png";

function begin()



{

surface = document.getElementById(canvasId);


if (surface.getContext) 
{
    wheel = new Image();
    wheel.onload = initialDraw;     
    wheel.src = wheelImageName;
}
}

This is the code now, My question is, how to modify this, to read the target image url from the example.php.

Thanks!

Richárd Kiss
  • 11
  • 2
  • 9
  • Go read up on AJAX. That's how you can communicate back and forth with your server. – Mike Cluck Jun 14 '16 at 21:51
  • @MikeC I know this, I have the open send things because I use it to get back data from another PHP file, but here I need to the get back the image URL and than put into the image source. Thats why I asked. wheel.src must be = with the GET data, and I dont know how to do. – Richárd Kiss Jun 14 '16 at 21:57
  • If you know how to use AJAX to make a request to your server then you know how to get the image URL. If you know how to get the image URL, you know how to assign it to `wheel.src`. – Mike Cluck Jun 14 '16 at 22:04
  • But I dont know how to use ajax, Its the 2nd time when I need to use, and I hope its the last time. ` var xhr = new XMLHttpRequest(); xhr.onreadystatechange = ajaxCallback; if (determinedGetUrl) { xhr.open('GET', determinedGetUrl, true); xhr.send(''); }` – Richárd Kiss Jun 14 '16 at 22:06
  • Then look up how to use AJAX. There's a massive number of tutorials on the subject. In fact, the "duplicate" question shows you how to use it. – Mike Cluck Jun 14 '16 at 22:07
  • It doesnt help for me. :c, but I tried so many ways to fix it. Its give back always nothink, and I dont know how to debug javascript applications, its not like PHP... – Richárd Kiss Jun 14 '16 at 22:41

0 Answers0