GithubHelp home page GithubHelp logo

jquerylessajax's Introduction

JQueryLessAjax

JQuery like syntax for AJAX without the whole of JQuery, for modern browsers.

Motivation

Rough and ready JQuery based syntax for AJAX at a small size.

Inspired by Rob Hawkes' tweet:

Necessary JS is fine. 
Whacking in the whole of jQuery for AJAX...
not so fine ;)

Caution

Rough and ready, quickly written, won't work in all cases - doesn't provide full functionality etc..

Usage

Download the minified library and include it in your html.

<script src="js/jqueryless-ajax.min.js"></script>

Get request with parameters returning JSON:

$.get(
    '/url_to_post_to?id=5',
    {data1: 34, name: "hello" },
    function callback(json){
        ... // do something with json
    },
    'json'
);

POST request with parameters an no return callback:

$.post(
    '/url_to_post_to?id=5',
    {data1: 34, name: "hello" }
);

POST request with parameters returning an ArrayBuffer:

$.post(
    '/url_to_post_to?id=5',
    {data1: 34, name: "hello" },
    function callback(arraybuffer){
        ... // do something with arraybuffer
    },
    'arraybuffer'
);

POST request returning HTML or text:

$.post(
    '/url_to_post_to',
    function callback(data){
        ... // do something with data
    },
    'text'
);

POST request returning JSON:

$.post(
    '/url_to_post_to',
    function callback(json){
        ... // do something with json
    },
    'json'
);

POST request returning a Uint8Array:

$.post(
    '/url_to_post_to',
    function callback(arraybuffer){
        var uint8Array = new Uint8Array(arraybuffer);
        ... // do something with uint8Array
    },
    'arraybuffer'
);

POST request returning a blob:

$.post(
    '/url_to_post_to',
    function callback(blob){
        ... // do something with blob
    },
    'blob'
);

POST request returning xml:

$.post(
    '/url_to_post_to',
    function callback(xml){
        ... // do something with xml
    },
    'document'
);

jquerylessajax's People

Contributors

benaadams avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.