URL is not a standard JavaScript object (thus the "not declared" message you receive) - what exactly are you trying to achieve? Maybe you should look into XMLHttpRequest() instead.
I do not know if you will find the following code useful:
// only check if 15 minutes have passed
if ((now - last_updated) > 900000)
{
if (xml_request != null)
{
xml_request.abort();
xml_request = null;
}
xml_request = new XMLHttpRequest();
Thx for the answer but I think I didnt told you why i need the fetch() method.
The fetch method takes the data(e.g. html) and puts it in a string variable or into a file.
I need this because I want to make a widget(I finished but one feature is missing) which opens a site and tells you how which trains or busses you need.
My Problem is that this site needs detailed information and so you have to choose on the site.
I want to put this choosing into my widget.
As you recognized the idea is like Ajax.
But i dont think that xmlhttprequest will work for my problem.