Answer»
- jQuery provides the ajax() method to perform an AJAX (asynchronous HTTP) request.
- Syntax: $.ajax({name:value, name:value, ... }). The parameters specify one or more values of name-value pairs.
url: this name specifies the URL to send the request to. Default is the current page.
success(result,status,xhr): success callback function which runs when the request succeeds
error(xhr,status,error): A function to run if the request fails.
async: Boolean value that indicates whether the request should be handled asynchronous or not. The default value is true.
complete(xhr,status): A function to run when the request is completed (after success and error functions are handled)
xhr: A function used for creating the XMLHttpRequest object
- Example:
$.ajax({ url: "resourceURL", async: false, success: function(result){ $("div").html(result); }, error: function(xhr){ alert("An error occured: " + xhr.status + " " + xhr.statusText); } });
|