Welcome to WebmasterWorld Guest from 23.20.37.222

Forum Moderators: open

Message Too Old, No Replies

Which to use: jquery .ajax or .post?

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

10+ Year Member



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)

WebmasterWorld Senior Member 5+ Year Member



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


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

$.ajax({
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)

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



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

Featured Threads

Hot Threads This Week

Hot Threads This Month