The use of the ajax()
method is the lowest, most powerful method of requesting server data, it can not only get the data returned by the server, but also send a request to the server and pass a numeric value, its invocation format is as follows:
jQuery.ajax([settings])
Or$.ajax([settings])
Where the parameter settings is the configuration object when the AJAX request is sent, in which the URL represents the path requested by the server, data is passed at the request, datatype is the data type returned by the server, success is the callback function for the successful execution of the request, Type is the way to send data requests by default to get.
For example, clicking the "Load" button in the page calls the ajax()
method to request the server to load a TXT file and displays the contents of the returned file in the page, as shown in:
Effects displayed in the browser:
As you can see, when the "Load" button is clicked, the calling $.ajax()
method requests the TXT file on the server, invokes the success callback function when the request succeeds, obtains the returned data, and displays it in the page.
Using the Ajax () method to load server data