Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs

Dashboard
Notifications
Mark all as read
Q&A

How to load two or more files in one AJAX call?

+0
−1

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 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:

ajax.open(
"GET",
"/index.html", 
"image.svg", 
false
);
Why does this post require moderator attention?
You might want to add some details to your flag.
Why should this post be closed?

1 comment thread

`open` accepts only one URL. You'll probably have to add a callback after the first request is finish... (3 comments)

0 answers

Sign up to answer this question »