Difference between $.post and $.ajax?

This jquery forum thread sums it up:

$.post is a shorthand way of using $.ajax for POST requests, so there isn’t a great deal of difference between using the two – they are both made possible using the same underlying code. $.get works on a similar principle.

—addyosmani

In short, this:

$.post( "/ajax", {"data" : json }) 

Is equivalent to the following:

$.ajax({ 
  type: "POST", 
  url: "/ajax", 
  data: {"data": json} 
});

Leave a Comment