Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

Which to use: jquery .ajax or .post?

4:22 am on May 17, 2012 (gmt 0)

Preferred Member

10+ Year Member

joined:Aug 20, 2004
posts: 615
votes: 0

Hello All -

Even though I've been coding php for years now, I'm just (amazingly) getting into javascript and jquery.

So far so good, but I'm confused by the various arguments and syntax needed for $.ajax or $.post functions when interacting with a database.

Is one better/more flexible than the other (it would seem that .ajax is more flexible).

I'm really getting into this now and would like to start off right - any suggestions gratefully accepted!

Also, if anyone can point me to some good newbie tutorials (on or off-list) for jquery database functions (.ajax/.post/whatever) that would also be great.
8:16 am on May 17, 2012 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Nov 3, 2005
votes: 0

[api.jquery.com...] says for $.post

This is a shorthand Ajax function, which is equivalent to:

type: 'POST',
url: url,
data: data,
success: success,
dataType: dataType

Similarly for $.load $.get etc. Master $.ajax, the rest are for convenience.
1:36 pm on May 17, 2012 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member fotiman is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Oct 17, 2005
votes: 21

It's important to note that jQuery/JavaScript does not do any direct interacting with a database. You can send HTTP requests to the server, but you still need some page on the server to handle the request and communicate with the database (probably a PHP page in your case).

Also, the jQuery API documentation is a good place to start. It's fairly well documented. :)