Git Product home page Git Product logo

aja.js's Introduction

aja.js Build Status NPM version Built with Grunt

Ajax without XML : Asynchronous Javascript and JavaScript/JSON(P)

Npm Downloads

Basic Sample

Request JSON data

  aja()
    .url('/api/data.json')
    .on('success', function(data){
        //data is a JavaScript object
    })
    .go();

Load html into an element

  aja()
    .url('/views/page.html')
    .into('.container')
    .go();

More options using the fluent api, terrific REST client.

  aja()
    .method('GET')
    .url('/api/customer')
    .timeout(2500)
    .data({firstname: 'John Romuald'})
    .on('200', function(response){
        //well done
    })
    .on('timeout', functon(){
        // uh oh... Request ended. Do something fancy here, don't let your user wait forever!
    })
    .go();

  aja()
    .method('PUT')
    .url('/api/customer')
    .cache(false)
    .body({id : 12, firstname: 'John Romuald', job : 'linguist'})
    .on('200', function(response){
        //well done
    })
    .on('40*', function(response){
        //something is definitely wrong
    })
    .on('500', function(response){
        //oh crap
    })
    .go();

JSONP

  aja()
    .url('http://otherdomain.com/api/remoteScript')
    .type('jsonp')
    .padding('someGlobalFunction')
    .on('success', function(data){
        //Fuk cross origin policy
    })
    .go();

Raw script loading

    aja()
      .url('http://platform.twitter.com/widgets.js')
      .type('script')
      .on('success', function(){
          window.twttr.widgets.load();
      })
      .go();

Development

Setup

You need grunt >= 0.4 as well as node and npm installed and running on your system.

git clone https://github.com/krampstudio/aja.js.git
cd aja.js
npm install

Tests

Run the tests:

grunt test

Development

The dev of this library is based on TDD principle. So, dev means write tests. Run the developent server :

grunt devtest

So tests run once something is modified and you can access it also at http://localhost:9901/test

Contributing

Contributions (issue reporting, bug fixes, feedback, typos, gimie a tip, etc.) are really welcomed! This library is developed using the TDD principles, so I accept pull request only if they come with the according unit/integration test.

I'd love if somebody can create a nice logo for aja.js...

History

  • 0.1.0 : initial release
  • 0.2.0 : added support of new HTTP methods (trace, patch and connect)
    • 0.2.1 : Fix missing main prop in package.json
  • 0.3.0 : support new request type : script
    • 0.3.1 : Fix issue #4 and cache management
    • 0.3.2 : Fix issue #7
    • 0.3.3 : Fix issue #10 and #11
    • 0.3.4 : reminify
  • 0.4.0 : added timeout
    • 0.4.1 : Merge PR #16

License

Copyright (c) 2014 Bertrand Chevrier <"chevrier_bertrand gmail_com".replace(/\s/, '@').replace(/_/g, '.')> Licensed under the MIT license.

aja.js's People

Contributors

e-jigsaw avatar janrywang avatar jsdotcr avatar krampstudio avatar oculus42 avatar palmerj3 avatar seanhak avatar

Watchers

 avatar  avatar  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.