Contact Form

Name

Email *

Message *

Cari Blog Ini

Ajax Post Request Javascript Example

JavaScript HTTP Request

Sending GET Requests

Request Parameters

When sending a GET request, request parameters can be included in the URL. For example, the following URL contains two request parameters, name and age, which will be sent to the server:

https://example.com/api/get?name=John&age=30

Sending POST Requests

Request Body

When sending a POST request, request data is typically included in the request body. The request body can be a string, a FormData object, or a Blob object. For example, the following code sends a POST request with a FormData object containing two request parameters, name and age:

const data = new FormData(); data.append('name', 'John'); data.append('age', 30); const request = new XMLHttpRequest(); request.open('POST', 'https://example.com/api/post'); request.send(data);


Comments

More from our Blog