Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript AJAX Basics (retiring) AJAX Concepts Create an XMLHttpRequest Object

Ronnie Barua
Ronnie Barua
17,665 Points

What am I missing here?

var request = new XMLHttpRequest object;

app.js
var request = new XMLHttpRequest object();
index.html
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>AJAX with JavaScript</title>
  <script src="app.js"></script>
</head>
<body>
  <div id="main">
    <h1>AJAX!</h1>
  </div>
  <div id="footer"></div>
</body>
</html>

3 Answers

Ronnie Barua
Ronnie Barua
17,665 Points

Thanks! I got it but I think this question is wrong and someone should fix this.

J Scott Erickson
J Scott Erickson
11,883 Points

What is the actual text of the question?

Dean Wagman
Dean Wagman
21,591 Points

Hi Ronnie, you want to assign the variable to a new XMLHttpRequest(); like so

var request = new XMLHttpRequest();

The "XMLHttpRequest()" is a function that gets ran, and returns an object to you, which you then are assigning to the variable. The new keyword tells JavaScript to create a new object with that function.

Let me know if you have any questions.

:)

J Scott Erickson
J Scott Erickson
11,883 Points
  var request = new XMLHttpRequest();