GithubHelp home page GithubHelp logo

jeffycai / flyjsonp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from alotaiba/flyjsonp

0.0 1.0 0.0 2.05 MB

FlyJSONP is a small JavaScript library, that allows you to do cross-domain GET and POST requests, with JSON response.

Home Page: http://alotaiba.github.com/FlyJSONP

License: Other

JavaScript 90.22% HTML 1.13% CSS 8.65%

flyjsonp's Introduction

Overview

FlyJSONP is a small JavaScript library, that allows you to do cross-domain GET and POST requests with remote services that support JSONP, and get a JSON response. Have a look at the demo to see it in action, or check out get started guide for usage instructions, and examples.

Links

Features

  • Cross-domain GET, as well as POST requests, with JSON response. POST requests pass through YQL.
  • Control over the callback parameter name for GET requests.
  • No other dependency on other JavaScript frameworks.

Quick Usage Guide

To get started, first download FlyJSONP, and add it to your code. Then simply call init method to setup the initial options.

<script src="/path/to/flyjsonp.js"></script>
<script>
FlyJSONP.init({debug: true});
</script>

GET Request

To issue a cross-domain GET request, you call the get method. It accepts number of options, and calls success callback when provided, with JSON response.

FlyJSONP.get({
  url: 'http://storify.com/xdamman.json',
  success: function (data) {
    console.log(data);
  },
  error: function (errorMsg) {
    console.log(errorMsg);
  }
});

POST Request

To issue a cross-domain POST request, you call the post method. It accepts number of options, and calls success callback when provided, with JSON response. To get around cross-domain issues for POST requests, FlyJSONP uses YQL to send the request and retrieve the response.

FlyJSONP.post({
  url: 'http://storify.com/story/new',
  parameters: {
    username: 'your-username',
    api_key: 'secret-api-key',
    title: 'FlyJSONP',
    description: 'Testing it out'
  },
  success: function(data) {
    console.log(data);
  }
});

License

FlyJSONP is a project of Abdulrahman Al-Otaiba, the project is dual-licensed under GNU GPLv3, and MIT. See LICENSE for more details.

Thanks

I would like to thank the following people, and give them credit for their awesome work:

  • Johannes Charman - For creating YQL data table 'jsonpost'
  • Christian Heilmann - For creating YQL data table 'htmlpost'

flyjsonp's People

Contributors

alotaiba avatar

Watchers

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