-1

I want to send an async HTTP request from the HTML, parse a response, and update an HTML page respectively. Is there a way to do it without using AJAX or any other third-party library?

I'd like to find the most basic way to do this. Since libraries can do it, it should be possible without them too.

Worth saying, that I'm a mobile developer who checks web development for a couple of days.

UPDATE 1

I didn't have to call AJAX a "third-party library". My bad.

UPDATE 2

Thanks everybody who responded. What I've learned: the only way to do what I wanted is AJAX, in particular, XMLHttpRequest.

Artem Stepanenko
  • 3,423
  • 6
  • 29
  • 51
  • Ajax is the name given to the process of "Making an HTTP request with JavaScript without leaving the current page". You can't do it without Ajax because they are the same thing. Ajax is not a third party library. Anything you can do with a library you can do without one because a library is just "JavaScript that someone else wrote". – Quentin Oct 07 '16 at 11:30
  • You want it to be asynchronous but don't want AJAX? That is kind of weird, since AJAX literally means "Asynchronous Javascript and XML" (although you can ignore the XML part) – Neikos Oct 07 '16 at 11:30
  • Here you have got browser api docs https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest – jonzee Oct 07 '16 at 11:30
  • With ajax only you can if you dont want to use jquery ajax you can always opt for `promise` – Aatif Bandey Oct 07 '16 at 11:31
  • @AatifBandey — That makes no sense at all. A promise isn't a way to make an HTTP request. – Quentin Oct 07 '16 at 11:32
  • You can't. AJaX is not a third party library. And HTML is not a scripting/programming language, only a text formatting language. – Marc Compte Oct 07 '16 at 11:37
  • @Quentin yes i know i was referring for aysnc tasks. – Aatif Bandey Oct 07 '16 at 12:39

1 Answers1

1

There is no way without JS. The most basic way is to either use the new fetch() API, or good old XMLHttpRequest() link

philipp
  • 15,947
  • 15
  • 61
  • 106
  • This link is also good ;) : https://davidwalsh.name/fetch – Steeve Pitis Oct 07 '16 at 11:32
  • Please [avoid link only answers](http://meta.stackoverflow.com/tags/link-only-answers/info). Answers that are "barely more than a link to an external site” [may be deleted](http://stackoverflow.com/help/deleted-answers). – Quentin Oct 07 '16 at 11:32
  • Technically it is possible to request external resources without JS, but not to accomplish what the OP wants to do...but in case anyone is curious: http://webcomponents.org/articles/introduction-to-html-imports/ – Matt Browne Oct 07 '16 at 11:36
  • I didn't say it should be without JS, just without libraries. – Artem Stepanenko Oct 07 '16 at 11:36
  • Than, you have two options listed above. – philipp Oct 07 '16 at 11:37
  • Regarding XMLHttpRequest: I thought, it's not possible, because when I used it in a script tag, I got a warning "XMLHttpRequest cannot load {url}. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource." Was it bacuse of a different reason? – Artem Stepanenko Oct 07 '16 at 11:38
  • That is because of security issues, search for CORS or JSONP to set it up – philipp Oct 07 '16 at 11:39
  • @philipp thank you. – Artem Stepanenko Oct 07 '16 at 11:41