![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@fdaciuk/ajax
Advanced tools
Ajax module in Vanilla JS
You can use this module with AMD, CommonJS or just like a method of window
object!
You can install via bower:
bower install ajax
Just download dist/ajax.min.js
file, and add dist/ajax.min.js
on your HTML file:
<script src="js/ajax.min.js"></script>
npm i --save @fdaciuk/ajax
You may use a CDN to get the latest version.
CDNJS:
https://cdnjs.com/libraries/fdaciuk-ajax
GitHub:
Or you may just add the following line to your HTML file:
<script src="//cdn.rawgit.com/fdaciuk/ajax/v1.0.10/dist/ajax.min.js"></script>
define(['ajax'], function(ajax) {
ajax().get(...)
...
})
var ajax = require('@fdaciuk/ajax')
ajax().post(...)
...
import ajax from 'ajax'
ajax().put(...)
window
objectwindow.ajax().get(...)
or just
ajax().get(...)
ajax([options])
Optional object with request options. See all accepted options below.
HTTP Methods
You may pass any HTTP method as you want, using method
property:
var request = ajax({
method: 'options',
url: '/api/users',
data: {
user: 'john'
}
})
request.then(function(response) {...})
For using this kind of request, you must pass url
property.
The property data
is optional, but may used to pass any data via body
on request.
headers
An object when key
is a header name, and value
is a header value.
ajax({
headers: {
'content-type': 'application/json',
'x-access-token': '123@abc'
}
})
If content-type
is not passed, application/x-www-form-urlencoded
will be used.
You may use any of this methods, instead the above approach:
get(url)
Get data as a JSON object.
ajax().get('/api/users')
post(url, [data])
Save a new register or update part of this one.
// Without headers
ajax().post('/api/users', { slug: 'john' })
// With headers
var request = ajax({
headers: {
'x-access-token': '123@abc'
}
})
request.post('/login', { username: 'user', password: 'b4d45$' })
put(url, [data])
Update an entire register.
ajax().put('/api/users', { slug: 'john', age: 37 })
delete(url, [data])
Delete a register.
ajax().delete('/api/users', { id: 1 })
then(response, xhrObject)
Promise that returns if the request was successful.
ajax().get('/api/users').then(function(response, xhr) {
// Do something
})
catch(responseError, xhrObject)
Promise that returns if the request has an error.
ajax().post('/api/users', { slug: 'john' }).catch(function(response, xhr) {
// Do something
})
always(response, xhrObject)
That promise always returns, independent if the status is
done
orerror
.
ajax().post('/api/users', { slug: 'john' }).always(function(response, xhr) {
// Do something
})
You may see the deprecated methods here
Check CONTRIBUTING.md
https://github.com/reportz/ajax
MIT © Fernando Daciuk
FAQs
Ajax module in Vanilla JS
The npm package @fdaciuk/ajax receives a total of 33 weekly downloads. As such, @fdaciuk/ajax popularity was classified as not popular.
We found that @fdaciuk/ajax demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.