Giter Site home page Giter Site logo

stoskov / najax Goto Github PK

View Code? Open in Web Editor NEW

This project forked from icenium/najax

0.0 2.0 0.0 130 KB

A lightweight wrapper for the nodejs http request object to enable jquery ajax style serverside requests in nodejs

License: MIT License

JavaScript 100.00%

najax's Introduction

najax

Travis CI Code Climate Dependency Status devDependency Status

Fast, flexible, unit-tested jquery-ajax-stye serverside requests.

jQuery ajax is stupid simple. This project provides a lightweight wrapper for the nodejs http request object that enables jquery ajax style syntax when making serverside requests to other webpages in node.js

It features very flexible method overloads to suit various styles, including with jquery style deferreds.

It seamlessly handles ssl and makes some reasonable assumptions based on inputs but as usual everything can be overridden by passing an options object.

Changelog

0.2.0

Breaking changes!

  • success and error callback arguments are now in jQuery.ajax order and format.
  • contentType must now be the full string, i.e. application/json, not just json.
  • Undocumented encoder option deprecated. Any object can already override its own toString().
  • CRLF (\n) removed from end of POST message body. It did not match HTTP spec.

Getting Started

Install the module with: npm install najax

var najax = require('najax');
najax('http://www.google.com', function(html){ console.log(html); }); // "awesome"
najax('http://www.google.com', { type:'POST' }, function(html){ console.log(html); }); // "awesome"
najax({ url:'http://www.google.com', type:'POST', success: function(html){ console.log(html); }); // "awesome"
najax({ url:'http://www.google.com', type:'POST' }).success(function(resp){}).error(function(err){}); // "awesome"

najax.get, najax.post, najax.put, najax.delete...

Run unit tests

  • cd dir
  • npm -g install grunt
  • npm install
  • grunt test

Examples

(Coming soon)

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using grunt.

License

Copyright (c) 2012-2015 Alan Clarke Licensed under the MIT license.

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.