1,105,534 Community Members

JQuery: difference between $.ajax and $.post

Member Avatar
t_thakar
Newbie Poster
18 posts since Mar 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi Im new to JQuery and sorry if this question sounds silly.
my question is what is the difference between $.ajax and $.post and which is best if I am posting some form to a php and retriving some values on the same page as the form

e.g. contact us page will post form and the php backend sends email and confirms everything ok back to the contact us page with some confirmation text specific to the type of email.

i think $.post can post the form to a php script and use the returned values to display in the page. but i dont know if $.ajax does the same and if it does why two different thing that does the same thing?

what is the difference ...

thanks everyone....

Member Avatar
pritaeas
mod_pritaeas
11,316 posts since Jul 2006
Reputation Points: 1,420 [?]
Q&As Helped to Solve: 1,835 [?]
Skill Endorsements: 156 [?]
Moderator
Featured
Sponsor
 
1
 

$.post is a subset of $.ajax. As you can read on the manual page: This is a shorthand Ajax function, which is equivalent to:

$.ajax({
  type: "POST",
  url: url,
  data: data,
  success: success,
  dataType: dataType
});
Question Answered as of 9 Months Ago by pritaeas
Member Avatar
t_thakar
Newbie Poster
18 posts since Mar 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

oh kool :) thanks for the fast reply

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: