Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
In my browser's JavaScript console I can add to the <body> element one file (index.html) with the following AJAX code: const whereToLoad = document.querySelector("body"); const ajax = new X...
Question
ajax
#3: Post edited
I can load just one file (index.html) with the following AJAX code:- ```javascript
- const whereToLoad = document.querySelector("body");
- const ajax = new XMLHttpRequest();
- ajax.open("GET", "/index.html", false);
- ajax.send();
- whereToLoad.innerHTML += ajax.responseText;
- ```
- I tried to change `ajax.open` to load two files instead, but that failed:
- ```javascript
- ajax.open(
- "GET",
- "/index.html",
- "image.svg",
- false
- );
- ```
- In my browser's JavaScript console I can add to the `<body>` element one file (index.html) with the following AJAX code:
- ```javascript
- const whereToLoad = document.querySelector("body");
- const ajax = new XMLHttpRequest();
- ajax.open("GET", "/index.html", false);
- ajax.send();
- whereToLoad.innerHTML += ajax.responseText;
- ```
- I tried to change `ajax.open` to load two files instead, but that failed:
- ```javascript
- ajax.open(
- "GET",
- "/index.html",
- "image.svg",
- false
- );
- ```
#2: Post edited
Using one AJAX call to load several files
- How to load two or more files in one AJAX call?
#1: Initial revision
Using one AJAX call to load several files
I can load just one file (index.html) with the following AJAX code: ```javascript const whereToLoad = document.querySelector("body"); const ajax = new XMLHttpRequest(); ajax.open("GET", "/index.html", false); ajax.send(); whereToLoad.innerHTML += ajax.responseText; ``` I tried to change `ajax.open` to load two files instead, but that failed: ```javascript ajax.open( "GET", "/index.html", "image.svg", false ); ```