ajax load() method
Translation results:
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() methodsyntax
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() methodexample
<!DOCTYPE html> <html> <head> <script src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"> </script> <script> $(document).ready(function(){ $("#btn1").click(function(){ $('#test').load('需要加载的文档地址'); }) }) </script> </head> <body> <h3 id="test">请点击下面的按钮,通过 jQuery AJAX 改变这段文本。</h3> <button id="btn1" type="button">获得外部的内容</button> </body> </html>
Popular Recommendations
- What is Load Balancing ?
- duckduckgo can't load this page
- Building a simple load balancer in Go
- NGINX with Node.js: Load Balancing, Serving Static Content, and SSL
- Speeding Up API Development: Handling High-Load Requests Efficiently with Python
- Whales Load Up 380 Million XRP as Ethereum, Dogecoin Signal Bullish Reversals