{"id":15680916,"url":"https://github.com/galeone/sa","last_synced_at":"2025-07-14T01:14:03.491Z","repository":{"id":17059984,"uuid":"19824638","full_name":"galeone/sa","owner":"galeone","description":"Simple Ajax: a lightweight library to make AJAX requests","archived":false,"fork":false,"pushed_at":"2024-12-27T14:13:22.000Z","size":16,"stargazers_count":11,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-07T11:39:40.308Z","etag":null,"topics":["ajax","ajax-request","javascript","json"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/galeone.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-05-15T15:26:11.000Z","updated_at":"2024-12-27T14:13:26.000Z","dependencies_parsed_at":"2025-03-11T01:32:35.471Z","dependency_job_id":"429a5917-8221-4c51-8e76-db5e6ca27b2e","html_url":"https://github.com/galeone/sa","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/galeone/sa","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/galeone%2Fsa","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/galeone%2Fsa/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/galeone%2Fsa/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/galeone%2Fsa/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/galeone","download_url":"https://codeload.github.com/galeone/sa/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/galeone%2Fsa/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265228987,"owners_count":23731092,"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":["ajax","ajax-request","javascript","json"],"created_at":"2024-10-03T16:46:16.078Z","updated_at":"2025-07-14T01:14:03.448Z","avatar_url":"https://github.com/galeone.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"sa - Simple AJAX\n================\n\nThe aim of sa is to provide a lightweight library to easy make AJAX requests.\n\nLearning by examples\n====================\n\n## Instantiate the AJAX object\n\n```javascript\nvar ajax = null;\ntry {\n  ajax = new AJAX();\n} catch(e) {\n  // handle error (XMLHttpRequest object not supported)\n}\n```\n\n## Instantiate the AJAX object for a CORS request\n\n```javascript\nvar ajax = null;\ntry {\n  var CORS = true;\n  ajax = new AJAX(CORS);\n} catch(e) {\n  // handle error (XMLHttpRequest object not supported)\n}\n```\n\n## GET request\n\n```javascript\najax.get('/somepage?parmeter=wat\u0026who=yello',function(data) {\n  // handle completed get request\n},\nfunction(statusCode, body) { // Handle failure\n  console.log(statusCode, body);\n});\n```\n\n## POST request\n```javascript\najax.post('/somepage', function(data) {\n  // Handle completed post request\n}, function(statusCode, body) { // Handle failure\n\n  console.log(statusCode, body);\n}, parameters);\n```\n\n## GET Request returning JSON\n\n```javascript\najax.getJSON('/somepage?parmeter=wat\u0026who=yello',function(data) {\n  // Handle json return object, like:\n  console.log(data.field1, data.field2);\n}, function(statusCode, body) { // Handle failure\n  console.log(statusCode, body);\n});\n```\n\n\n## Generic request\n\nYou can build your own request.\n```javascript\najax.request({\nurl: '/wow',\n  type: 'post',\n  dataType: 'json',\n  data: {wow: 'amazing', 'param2': 1},\n  async: true, // true is the default when the field is not set\n  success: function(json) {\n    alert(json.responseField2);\n  },\n  failure: function(statusCode, body) {\n    alert(\"Request failed with status code: \" + statusCode);\n    alert(\"Request failed with body: \" + body);\n  }\n});\n```\nIn the example above we do a POST request to /wow and we expect to obtain a JSON object in response.\n\nWe could specify JSON or XML for the expected format of the response. Empty field means HTML.\n\n## Parameters\nAs you can see from the examples, you can use JSON object or a literal string to pass parameters.\n\nTo specify other parameters in `AJAX.request` you have to follow the definition below.\n```javascript\n//define generic ajax request parameter\n{\n  type: '',\n  url: '',\n  data: '',\n  dataType: '',\n  async: bool,\n  success: function(data){},\n  failure: function(errorCode, body){}\n};\n```\n\nWith:\n\n+ type = get|post\n+ url = whatever you want\n+ data: string|JSON\n+ dataType: \"JSON\"|\"XML\"|\"\"\n+ async: undefined|true|false - when undefined, async is true by default\n+ success = function(data) {}\n+ failure = function(errorCode, body) {}\n\n## License\n\nsa is licensed under the terms of MIT licence.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgaleone%2Fsa","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgaleone%2Fsa","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgaleone%2Fsa/lists"}