How do you make an AJAX call in jQuery?

Answer:

$.ajax({
  url: "data.json",
  method: "GET",
  success: function(response){
console.log(response);
} });

Also simpler shortcuts:

  • $("#div").load("file.txt");
  • $.get("file.txt", callback);
  • $.post("server.php", data, callback);

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *