If you have any query feel free to chat us!
Happy Coding! Happy Learning!
To make an AJAX request with jQuery, you can use the $.ajax()
method. Here is an example:
javascriptCopy code
$.ajax({
url: "https://jsonplaceholder.typicode.com/posts",
method: "GET",
dataType: "json",
success: function(data) {
console.log(data);
},
error: function(jqXHR, textStatus, errorThrown) {
console.log(textStatus, errorThrown);
}
});
This example makes a GET request to the https://jsonplaceholder.typicode.com/posts
endpoint and expects a JSON response. The success
function will be called if the request succeeds, and the error
function will be called if the request fails.
You can also use shorthand methods for common types of requests. For example, to make a GET request:
javascriptCopy code
$.get("https://jsonplaceholder.typicode.com/posts", function(data) {
console.log(data);
});
And to make a POST request:
javascriptCopy code
$.post("https://jsonplaceholder.typicode.com/posts", {title: "My post", body: "This is my post."}, function(data) {
console.log(data);
});
These shorthand methods are just shortcuts for calling $.ajax()
with some default options.
Comments: 2
I am not able to access videos from second class and further. I have already completed first class
When will I get my course?
Now, Your query was resolved.