Home > Web Front-end > JS Tutorial > Detailed explanation of user non-refresh login method based on jquery ajax_jquery

Detailed explanation of user non-refresh login method based on jquery ajax_jquery

WBOY
Release: 2016-05-16 17:54:02
Original
1347 people have browsed it

The Ajax framework is a collection that provides modular implementation of Ajax functions. The Ajax framework can be implemented in various languages ​​(for example, SAJAX has implementations in various languages). Ajax is only a part of jquery.

Example 1

Copy code The code is as follows:

$.ajax({
type:'post',/ /Optional get
url:'action.php',//This is the PHP program that receives data
data:'data='dsa',//The data passed to PHP, multiple parameters are connected with &
dataType:'text',//The data type returned by the server can be XML, Json jsonp script html text, etc.
success:function(msg){
//Here is the PHP program after the ajax submission is successful The returned data processing function. msg is the returned data, and the data type is defined in the dataType parameter!
},
error:function(){
Ajax submission failure processing function! >})


PHP action.php


echo 'www.jb51.net!';
?>


The following is a jquery ajax user login example without refresh

Example 2



jQuery Ajax Demonstration






Enter name:


Enter password:










php code



echo json_encode(array ('username'=>$_REQUEST['username'],'password'=>$_REQUEST[ 'password']));
?>


Analysis of advantages and disadvantages of using jquery ajax

Advantages
Small, the compressed code is only more than 20k (uncompressed code is 94k).
Convenience of Selector and DOM operations: jQuery's Selector compared with mootools' Element.Selectors.js, CSS Selector, XPath Selector (deleted after 1.2)
Chaining: Always returns a jQuery object, which can be operated continuously.
The documentation is complete and easy to use (each API has complete examples, which is unmatched by other frameworks now), and there are many other documents and books on the Internet.
It is widely used, including google code also uses jQuery.

Site using jQuery: http://docs.jquery.com/Sites_Using_jQuery
Core development team and core personnel: John Resig, etc.
Concise and short syntax, easy to remember.
Extensibility: There are a large number of user-developed plug-ins available (http://jquery.com/plugins/)
jQuery UI (http://jquery.com/plugins/, based on jQuery, but Core jQuery is independent) and is constantly being developed.
Friendly and active community: google groups: http://docs.jquery.com/Discussion
There are many convenient methods for event handling, such as click, instead of a single addEvent and the like.

Disadvantages
Since the design idea is to pursue efficiency and simplicity, there is no object-oriented extension. The design idea is different from Mootools.
CSS Selector is a little slow (but now the speed has been greatly improved)
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template