Home  >  Article  >  Web Front-end  >  How jquery implements ajax technology 1: $.ajax()

How jquery implements ajax technology 1: $.ajax()

黄舟
黄舟Original
2016-12-21 15:42:141048browse

ajax technology is very important in web development. In early js, if you need to complete the effect of asynchronous transmission, you need to judge the browser, virtually access files, monitor, obtain return values, and a series of very tedious operations. But jQuery provides us with several very simple functions that allow us to easily implement ajax functions. In the next few articles, we will introduce these functions one by one.
First, let’s introduce $.ajax. This method is the underlying AJAX implementation of jQuery.
The usual syntax is:
$.ajax([settings])//settings is the parameter of the $.ajax() method and is a collection of key-value pairs used to configure Ajax requests.
Let’s introduce some of the more important parameters in $.ajax() one by one
url---the address to send the request
type---request method ("POST" or "GET")
timeout---setting Request timeout (milliseconds)
async---(Default: true) Asynchronous request.
Data---The parameters sent can be of json type
dataType---Returned data type: xml, html, json, txt
Success---After success, function(data,st){} can be returned
Actual examples are as follows :
================================================ ================
ajax.html

Application of $.ajax

$.ajax application

This is the place that needs to be displayed

============================================ ======================

ajax.php

echo 'The website you want to visit is'.$_POST['web '];

?>

The above is the content of how jquery implements ajax technology 1: $.ajax(). For more related content, please pay attention to the PHP Chinese website (www.php.cn)!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn