GithubHelp home page GithubHelp logo

lavioli / elitejax Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ghostffcode/elitejax

1.0 2.0 0.0 186 KB

Simplifying Ajax Requests Using HTML attributes

License: MIT License

JavaScript 81.40% HTML 18.60%

elitejax's Introduction

elitejax

Build Status Bower version

Simplifying Ajax Requests Using HTML attributes

Introduction


Elitejax is a standalone javascript library that makes AJAX requests a lot more easier without you writing a single line of javascript.

All you have to do is add data-elitejax="true" attribute to your form tag and you are good to go

Example

  • To send an AJAX request to the spotify API Endpoint, searching for artists by name:
<form data-elitejax="true" action="https://api.spotify.com/v1/search" method="get">
  Enter Artist name: <input type="text" name="q"><br />
  <input type="hidden" name="type" value="artist">
  <input type="submit" value="Submit">
</form>

<!-- include elitejax library from bower components directory -->
<script src="bower_components/elitejax/build/elitejax.min.js" charset="utf-8"></script>

Installation


You can install this library by cloning this git and reference the javascript files from the build directory or using bower:

bower install elitejax

Sample Usage Video

elitejax

Exclude form field


To exclude a form field in your form from your AJAX request, you can add data-ej-x attribute to that field, like:

<!-- below form field will be ignored -->
<input type="input" data-ej-x />

Adding custom configurations


Due to elitejax's flexibility, you can add custom configuration for each form in your webpage. First specify a name for your form and then use it with ej.configure, like so:

<form name="spotify" action="" method="get">
.....

</form>

<script type="text/javascript">
    ej.configure('spotify'[, {configuration}]);
</script>

The configuration object argument for the configure method takes 4 parameters:

  • async default: true : You can set this to true or false

  • cType default: "application/json" : This is the content type header.

  • resType default: "json" : This is the response type of the AJAX query, you can use jsonp for cross domain requests.

  • callback default: function : The default callback logs the data to the console. You can specify your callback function for when the request completes successfully

License

Elitejax is Licensed under the MIT License

Contributing

Please do! Send a pull request after your modifications.

Sharing is caring.... make sure to let your peers know.

elitejax's People

Contributors

ghostffcode avatar

Stargazers

 avatar

Watchers

 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.