Ajax, jqueryajax

Source: Internet
Author: User

Ajax, jqueryajax
AJAX, Asynchronous JavaScript and XML (Asynchronous JavaScript and XML), a web development technical solution for creating interactive web applications. Asynchronous JavaScript: Use the [JavaScript language] and related [browser class library] functions to send requests to the server. After the server completes processing the requests, [automatically execute a JavaScript callback function ]. PS: the whole process of the above request and response is [secretly], and there is no perception on the page. XMLXML is a markup language. It is one of the formats in which Ajax transmits data during interaction with the background. AJAX can be used: 1. When registering, enter the user name to automatically detect whether the user already exists. 2. When logging in, the system prompts that the user name and password are incorrect. 3. When the data is deleted, the row ID is sent to the background, and the background is deleted from the database. After the database is deleted successfully, delete data rows in the page DOM. Jquery-Ajax 1. Download and import jQuery, put it in the static directory 2. Import the configuration in setting 3. Reference jQuery in HTML

$. Ajax ({url: '/index/', type: 'post', data: {'username': 'Alex ', 'Password': '000000'}, success: function (data) {// This function is automatically executed after return in the background // data is the data returned in the background }})

Let's take a look at the example front-end page: <! DOCTYPE html> View. py in Django

Import jsondef ajax_demo (request): if request. method = 'post': ret = {'status': False, 'message': ''} user = request. POST. get ('user', None) pwd = request. POST. get ('pwd', None) if user = '000000' and pwd = '000000': # return HttpResponse ('1 ') ret ['status'] = True return HttpResponse (json. dumps (ret) else: # return HttpResponse ('2') ret ['message'] = 'user name or Password error! 'Return HttpResponse (json. dumps (ret) return render(request,'ajax_demo.html ')View Code ajax implemented based on jQuery can be said to be the most convenient and easy to use. In fact, jQuery cannot directly respond to ajax, but uses XMLHttpResponse to respond accordingly. XMLHttpResponse is also called Native ajax. For details, see Wu sir's AJAX full set.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.