{"id":17474144,"url":"https://github.com/ghostffcode/elitejax","last_synced_at":"2025-04-22T10:44:38.515Z","repository":{"id":57222425,"uuid":"67166222","full_name":"ghostffcode/elitejax","owner":"ghostffcode","description":":sparkles: Simplifying Ajax Requests Using HTML attributes","archived":false,"fork":false,"pushed_at":"2016-11-28T03:19:25.000Z","size":396,"stargazers_count":14,"open_issues_count":0,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-06T05:04:48.733Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://ghostffcode.github.io/elitejax/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ghostffcode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-01T21:04:44.000Z","updated_at":"2024-04-04T06:35:17.000Z","dependencies_parsed_at":"2022-08-30T16:11:34.296Z","dependency_job_id":null,"html_url":"https://github.com/ghostffcode/elitejax","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostffcode%2Felitejax","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostffcode%2Felitejax/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostffcode%2Felitejax/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostffcode%2Felitejax/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ghostffcode","download_url":"https://codeload.github.com/ghostffcode/elitejax/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249259146,"owners_count":21239422,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-18T18:08:33.149Z","updated_at":"2025-04-16T16:31:51.395Z","avatar_url":"https://github.com/ghostffcode.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# elitejax\n\n[![Build Status](https://travis-ci.org/ghostffcode/elitejax.svg?branch=master)](https://travis-ci.org/ghostffcode/elitejax) [![Bower version](https://badge.fury.io/bo/elitejax.svg)](https://badge.fury.io/bo/elitejax)\n\nSimplifying Ajax Requests Using HTML attributes\n\n### **Introduction**\n---\nElitejax is a standalone javascript library that makes AJAX requests a lot more easier without you writing a single line of javascript.\n\nAll you have to do is add data-elitejax=\"true\" attribute to your form tag and you are good to go\n\n### **Installation**\n---\nYou can install this library by cloning this git and reference the javascript files from the build directory, using npm:\n```\nnpm install elitejax --save\n```\nor using bower:\n```\nbower install elitejax\n```\n\n### Usage Without javascript\nIf your request returns data as JSON, you can add to the DOM from that object without javascript using the `data-post` and `data-postTo` attributes in your form element.\n\nThe `data-post` attribute is used to specify what part of the data returned you want to use.\n`data-postTo` is the DOM selector of where to post the resulting value.\n\n```html\n\u003c!-- using the spotify API --\u003e\n\u003cdiv class=\"result\"\u003e\u003c/div\u003e\n\u003cform name=\"spotify\" data-elitejax=\"true\" action=\"https://api.spotify.com/v1/search\" data-post=\"artists.items[1].name\" method=\"get\" data-postTo=\".result\" \u003e\n  Enter name: \u003cinput type=\"text\" name=\"q\"\u003e\u003cbr /\u003e\n  Category: \u003cinput type=\"text\" name=\"type\" value=\"artist\"\u003e\u003cbr /\u003e\n  \u003cinput type=\"submit\" value=\"Submit\"\u003e\n\u003c/form\u003e\n\u003cscript src=\"path/to/elitejax.min.js\" charset=\"utf-8\"\u003e\u003c/script\u003e\n```\nThe above will place the result in the div element with .result class.\n\n### Exclude form field\n___\nTo exclude a form field in your form from your AJAX request, you can add data-elitejax-x attribute to that field, like:\n```html\n\u003c!-- below form field will be ignored --\u003e\n\u003cinput type=\"input\" data-elitejax-x /\u003e\n```\n\n### Adding custom configurations\n---\nDue 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:\n\n```html\n\u003cform data-elitejax=\"true\" name=\"spotify\" action=\"https://api.spotify.com/v1/search\" method=\"get\"\u003e\n.....\n\n\u003c/form\u003e\n\u003c!-- include elitejax library from bower components directory --\u003e\n\u003cscript src=\"bower_components/elitejax/build/elitejax.min.js\" charset=\"utf-8\"\u003e\u003c/script\u003e\n\u003cscript type=\"text/javascript\"\u003e\n    elitejax.configure('spotify'[, {configuration}]);\n\u003c/script\u003e\n```\n\nThe configuration object argument for the configure method takes 4 parameters:\n\n* async **default: true** : You can set this to true or false\n\n* cType **default: \"application/json\"** : This is the content type header.\n\n* resType **default: \"json\"** : This is the response type of the AJAX query, you can use jsonp for cross domain requests.\n\n* callback **default: function** : The default callback logs the data to the console. You can specify your callback function for when the request completes successfully\n\n### Making Custom AJAX requests\n---\nYou can use the elitejax ajaxIt method to send a custom AJAX request:\n```javascript\nelitejax.ajaxIt(url, method, data[, requestName]);\n```\n* url **(string)** : the API Endpoint or url the request is to be made to.\n* method **(string)** : can be get/post/delete/put request type.\n* data **(object)** : data you want to send to the url\n* requestName - optional **(string)** : The name you want to give to your AJAX request. You need to set this if you want to use custom configuration (the elitejax configure method) with your AJAX request.\n\nSo, we can customize the spotify API call to run on page load instead of depending on user interaction like so:\n```html\n\u003cscript src=\"bower_components/elitejax/build/elitejax.min.js\" charset=\"utf-8\"\u003e\u003c/script\u003e\n\u003cscript type=\"text/javascript\"\u003e\n  window.onload = function () {\n    var data = {\n      q: 'Justin',\n      type: 'artist'\n    }\n    elitejax.ajaxIt('https://api.spotify.com/v1/search', 'get', data, 'spotifyCustom');\n  }\n\u003c/script\u003e\n```\n\n## **License**\nElitejax is Licensed under the [MIT License](../master/LICENSE)\n\n## **Contributing**\nPlease do! Send a pull request after your modifications.\n\nSharing is caring.... make sure to let your peers know.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghostffcode%2Felitejax","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fghostffcode%2Felitejax","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghostffcode%2Felitejax/lists"}