homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Gold Sponsor 2015!
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

Which to use: jquery .ajax or .post?

10+ Year Member

Msg#: 4454414 posted 4:22 am on May 17, 2012 (gmt 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.



WebmasterWorld Senior Member 5+ Year Member

Msg#: 4454414 posted 8:16 am on May 17, 2012 (gmt 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.


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

Msg#: 4454414 posted 1:36 pm on May 17, 2012 (gmt 0)

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. :)

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved