Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the common method of ajax in jquery

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the relevant knowledge of "what are the common methods of ajax in jquery". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "what is the common method of ajax in jquery" can help you solve the problem.

JQuery ajax framework

1Zero load () method

Function: used to load remote HTML code and insert it into DOM

Example:

$("# hello") .load ("text.html")

2 get method

The get () method requests data from the server through a http get request

Syntax: $.get (URL,data,callback)

Where: the URL address of the html page requested by url (String)

Data: data passed

Callback (data,status): callback function when the request is completed. Data refers to the address of the response from the server, status.

Refers to the response status of the server request

3. Post method

The post () method retrieves data from a file on the server

Its syntax is similar to get.

4Based serizlize method

Purpose: used to convert element names and values in the form to URL parameter format

Syntax: $() .serizlize ()

Example: $("# form1") .serizlize ()

Means to serialize the element name and value of the form with the name form1

5Gen Ajax () method

The common parameters are:

The address from which the url---- sent the request

Type---- request method: get and post

Timeout--- sets the request timeout

Async---- defaults to true as asynchronous request, and false to synchronous request.

This event is triggered before the beforeSend--- sends the request

Cache- defaults to true that if false, request information will not be loaded from the browser cache

This event is triggered after the complete--- request ends

The type of content encoding when contentType---- sends information to the server

Data sent by data---- to the server

The type of data that dataType--- expects the server to return

This method is called when an error- request fails

Setting global--- to false will not trigger global ajax events

IfModified--- only acquires new data when the server data changes

The data sent by processData--- will be converted to objects

Callback function after successful success- request

Example:

$(document) .ready (function () {

$("input [type=button]") .click (function () {/ / load when the html is finished

$.ajax ({/ / call the ajax method

Type: "post"

Data: {username:$ ("# username") .val (), password:$ ("# password") .val ()}

Url: "Login"

Async:true

Success:suc

Error:err

})

})

})

This is the end of the content about "what are the common methods of ajax in jquery". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report