ajax get() method
Translation results:
Ajax
English [ˈeɪˌdʒæks] American [ˈeˌdʒæks]
n. The full name is "Asynchronous JavaScript and XML" (asynchronous JavaScript and XML); refers to a A web development technology for creating interactive web applications. ;Ajax copper-tin-lead bearing alloy, Ajax explosive
get
UK[get] 美[ɡɛt]
vt.get ; catch; persuade; receive (punishment, etc.)
vt.& vi. arrive, come
vi.become; start; try to deal with; obtain benefits or wealth
n.Reproduction, cub; profit
ajax get() methodsyntax
Function: get() method loads information through remote HTTP GET request. This is a simple GET request function to replace the complex $.ajax. The callback function can be called when the request is successful. If you need to execute a function on error, use $.ajax.
Syntax: $(selector).get(url,data,success(response,status,xhr),dataType)
Parameters:
Parameters | Description |
Required. Specifies the URL to which the request will be sent. | |
Optional. Specifies the data to be sent to the server with the request. | |
Optional. Specifies a function to run when the request succeeds. Additional parameters: response - Contains the result data from the request status - Contains the status of the request xhr - Contains the XMLHttpRequest object. | |
Optional. Specifies the data type of expected server response. By default, jQuery will figure it out intelligently. Possible types: "xml" "html" "text" "script" "json" "jsonp" |
Description: This function is abbreviated Ajax function, equivalent to: $.ajax({ url: url, data: data, success: success, dataType: dataType}); Depending on the different MIME types of the response, the return data passed to the success callback function is also different. The data can be XML root elements, text strings, JavaScript files, or JSON objects. You can also pass the textual status of the response to the success callback function.
ajax get() methodexample
<!DOCTYPE html> <html> <head> <script src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $.get("获取数据的文件地址",function(data,status){ alert("数据:" + data + "\n状态:" + status); }); }); }); </script> </head> <body> <button>向页面发送 HTTP GET 请求,然后获得返回的结果</button> </body> </html>