JQuery Ajax Universal JS Package

Source: Internet
Author: User
Tags jquery library

First step: Introducing the jquery Library

  

JQuery Ajax Package General Class (ZZW) ********* /$ (function () {/** * Ajax package * URL Send request address * data send Data to the server, array storage, such as: {"date": new Date (). GetTime (), "state": 1} * Async default: True. By default, all requests are asynchronous requests.     If you need to send a synchronization request, set this option to false.     * Note that the sync request will lock the browser, and the user's other actions must wait for the request to complete before it can be executed. * Type Request method ("POST" or "get"), default to "get" * DataType expected server return data type, commonly used such as: XML, HTML, JSON, text * SUCCESSFN successful callback function * ER RORFN Failure callback function */jquery.ax=function (URL, data, async, type, DataType, SUCCESSFN, errorfn) {async = (async==n ull | | async== "" | | typeof (Async) = = "undefined")?        "True": async; Type = (Type==null | | type== "" | | typeof (type) = = "undefined")?        "POST": type; DataType = (Datatype==null | | datatype== "" | | typeof (DATATYPE) = = "undefined")?        "JSON": dataType; data = (Data==null | | data== "" | | typeof (DATA) = = "undefined")? {"Date": New DaTe (). GetTime ()}: data; $.ajax ({type:type, Async:async, Data:data, Url:url, DataType:            DataType, Success:function (d) {SUCCESSFN (d);            }, Error:function (e) {ERRORFN (e);    }        });        }; /** * Ajax Package * URL to send the requested address * data sent to the server, array storage, such as: {"date": new Date (). GetTime (), "state": 1} * SUCCESSFN Success Callback function */jquery.axs=function (URL, data, SUCCESSFN) {data = (Data==null | | data== "" | | typeof (DATA) = = "Undef Ined ")?        {"Date": new Date (). GetTime ()}: data; $.ajax ({type: "Post", Data:data, Url:url, DataType: "JSON", SUCC            Ess:function (d) {SUCCESSFN (d);    }        });        }; /** * Ajax Package * URL to send the requested address * data sent to the server, array storage, such as: {"date": new Date (). GetTime (), "state": 1} * dataType pre-     Type of data returned by the server, such as XML, HTML, JSON, text* SUCCESSFN Success Callback function * ERRORFN failed callback function */jquery.axse=function (URL, data, SUCCESSFN, ERRORFN) {data = (dat A==null | | data== "" | | typeof (data) = = "undefined")?        {"Date": new Date (). GetTime ()}: data; $.ajax ({type: "Post", Data:data, Url:url, DataType: "JSON", SUCC            Ess:function (d) {SUCCESSFN (d);            }, Error:function (e) {ERRORFN (e);    }        }); };
<%@ page language= "java" pageencoding= "Utf-8"%><%String Path=Request.getcontextpath (); String BasePath= Request.getscheme () + "://" + request.getservername () + ":" +Request.getserverport ()+ path + "/";%><! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >        $(function() {$.ax (Getrootpath ()+ "/test/ajax.html",                NULL,                NULL,                NULL,                NULL,                 function(data) {alert (data.code); },                 function() {alert ("Something went wrong.");                        }            ); $.axs (Getrootpath ()+ "/test/ajax.html",NULL,function(data) {alert (data.data);                    }); $.axse (Getrootpath ()+ "/test/ajax.html",                NULL,                 function() {alert ("It worked."); },                function() {alert ("Something went wrong.");        });          }); </script> 
<%@ page language= "java" pageencoding= "Utf-8"%><%String Path=Request.getcontextpath (); String BasePath= Request.getscheme () + "://" + request.getservername () + ":" +Request.getserverport ()+ path + "/";%><! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >        $(function() {$.ax (Getrootpath ()+ "/test/ajax.html",                NULL,                NULL,                NULL,                NULL,                 function(data) {alert (data.code); },                 function() {alert ("Something went wrong.");                        }            ); $.axs (Getrootpath ()+ "/test/ajax.html",NULL,function(data) {alert (data.data);                    }); $.axse (Getrootpath ()+ "/test/ajax.html",                NULL,                 function() {alert ("It worked."); },                function() {alert ("Something went wrong.");        });          }); </script> 

});

  

JQuery Ajax Universal JS Package

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.