This is a basic AJAX request to elicit new comments from the database. I choose to show the GET Method but you can, of course, send data packets through the POST method.
var commentNumber = 10;
First of all, $.ajax( ); method had started an AJAX request throughout the server.
I defined the request values by using ajax method parameters which are well-explained below.
According to which number of comment I want to show, I sent contentNumber via the GET Method.
If the requested page turns a success message, its result - comments - is added under the element named commentBar as child elements via .append( ); method.
|A Boolean value indicating whether the request should be handled asynchronous or not. Default is true
|A function to run before the request is sent
|A Boolean value indicating whether the browser should cache the requested pages. Default is true
|A function to run when the request is finished (after success and error functions)
|The content type used when sending data to the server. Default is: "application/x-www-form-urlencoded"
|Specifies the "this" value for all AJAX related callback functions
|Specifies data to be sent to the server
|A function used to handle the raw response data of the XMLHttpRequest
|The data type expected of the server response.
|A function to run if the request fails.
|A Boolean value specifying whether or not to trigger global AJAX event handles for the request. Default is true
|A Boolean value specifying whether a request is only successful if the response has changed since the last request. Default is: false.
|A string overriding the callback function in a jsonp request
|Specifies a name for the callback function in a jsonp request
|Specifies a password to be used in an HTTP access authentication request.
|A Boolean value specifying whether or not data sent with the request should be transformed into a query string. Default is true
|Specifies the charset for the request
|A function to be run when the request succeeds
|The local timeout (in milliseconds) for the request
|A Boolean value specifying whether or not to use the traditional style of param serialization
|Specifies the type of request. (GET or POST)
|Specifies the URL to send the request to. Default is the current page
|Specifies a username to be used in an HTTP access authentication request
|A function used for creating the XMLHttpRequest object