This is a reading note for jQuery Tutorial on TutorialsPoint.com, including useful functions/concepts for web development using jQuery. Please note I only pick parts of core concept which I will use most often.
This reading note is based on
Note: All tips that is written by book will has a sign near it.
All code example in this post comes from offical documents.
XX.load(URL, Optional:data, Optional:callback) is used to load data:
- URL: can be
PHPscript which generate data from database.
- data: Optional. if this is ommitted,
GETmethod is used. If specified,
POSTmethod is used.
- callback: callback function to deal with data after loading. The first parameter passed to this function is the response text received from the server and second parameter is status code.
Get JSON Data
XXX.getJSON(URL, Optional:data, Optional:callback) is used to get JSON string:
- URL: the server-side source which can be reach via
- data: Optional. You can pass
name/valuepair to do sring query.
- callback: Optional. Call back function to deal with data after loading. The first parameter is the JSON string which is passed back based on request. The second parameter is the status code.
Pass Data to Server
You can use
data parameter to pass data to server via any ajax call. For example:
jQuery Ajax Methods and Events
Show or Hiding or Toggle Elements
XXX.show(speed,Optional:callback) is used to show the elements.
speed can be
fast or any milliseconds.
callback is optional. You run this function after the animation completes.
XXX.hide(speed,Optional:callback) is the same as above:
XXX.toggle(Optional:speed, Optional: callback) is used to toggel elements.
Other jQuery Events