Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Development Tools HTTP Basics Introduction to HTTP HTTP Request Format

How would I make a http request on a regular html page? Where would it go?

I am trying to do this in a real life situation. I want to successfully get a response from another server.

1 Answer

Steven Parker
Steven Parker
218,679 Points

Two of the most common ways to make requests from an HTML page are by using links ("a" elements, also known as "anchors") and forms ("form" elements). Links make GET requests, and the response replaces the page currently being shown. With forms, you can specify what kind of request to make, and the results will depend on how the server is programmed to respond.

Examples:

<body>
<!-- this makes a GET request to google.com -->
<a href="//google.com">Go to Google</a>

<!-- this makes a POST request to a specific page on the same site -->
<form action="some_form_page.php" method="post">Form fields would go here</form>
</body>

You'll see more details on both of these later in the course.