load

英[ləʊd] 美[loʊd]

n.Load; load; burden; workload

vt. To bear ;Load; load or load...; fill, pile up

vi.Load; load; load

ajax load() method syntax

Function:The load() method loads data from the server through AJAX requests and places the returned data into the specified element. There is also a jQuery event method called load . Which one is called depends on the parameters.

Syntax:load(url,data,function(response,status,xhr))

Parameters:

Parameters Description
url Specifies which URL to send the request to.
data Optional. Specifies the data to be sent to the server with the request.
function(response,status,xhr) Optional. Specifies a function to run when the request completes. Additional parameters: response - Contains the result data from the request status - Contains the status of the request ("success", "notmodified", "error", "timeout" or "parsererror") xhr - Contains the XMLHttpRequest object

Description:This method is the simplest method to obtain data from the server. It is almost equivalent to $.get(url, data, success), except that it is not a global function and it has an implicit callback function. When a successful response is detected (for example, when textStatus is "success" or "notmodified"), .load() sets the HTML content of the matching element to the returned data. This means that most uses of this method will be as simple as: $("#result").load("ajax/test.html"); If a callback function is provided, it will be executed after post-processing: $ ("#result").load("ajax/test.html", function() {alert("Load was performed.");});In the above two examples, if the current document does not contain the "result" ID , the .load() method will not be executed. If the data provided is an object, the POST method is used; otherwise, the GET method is used.

ajax load() method example

     

请点击下面的按钮,通过 jQuery AJAX 改变这段文本。