
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@ephox/jax
Advanced tools
jax
is a library for handling AJAX requests and responses. It does not bundle any commands. It is only a collection of modules.
jax
is available as an npm
package. You can install it via the npm package @ephox/jax
npm install @ephox/jax
.
jax
supports several methods, content types, and response types. More specifically,
Methods: GET, POST, PUT, DELETE Content Types: none, form, json, plain, html Response Types: json, blob, text, html, xml
In addition, credentials
can be sent with the request. More information can be found here.
The ephox.jax.api.Ajax
APIs provide the various methods for making AJAX requests. They all return a LazyValue
(see katamari) which is a promise-like data structure with get
, map
, and isReady
functions. The APIs also take an additional parameter at the end for any custom request headers, which defaults to {}
if it is not provided.
ContentType
, ResponseType
, and Credentials
are specified using the constructors inside ephox.jax.api.ContentType
, ephox.jax.api.ResponseType
, and ephox.jax.api.Credentials
respectively.
Ajax.get(url, responseType, credentials, _custom)
This fires a GET request with the specified response type. The content type is sent as none
.
Ajax.get(
'http://localhost/server/get/1',
ResponseType.json(),
Credentials.none(),
{ }
).get(function (result) {
// result is a result, so you need to fold over it for Err or Succ(x)
result.fold(function (err) {
console.error('Server error', err);
}, function (val) {
console.log('Get response', val);
})
});
Ajax.post(url, contentType, responseType, credentials, _custom)
This fires a POST request with the specified response type and content type.
Ajax.post(
'http://localhost/server/post',
ContentType.json({
'send-data': '10'
}),
ResponseType.xml(),
Credentials.none(),
{ }
)).get(function (result) {
// result is a result, so you need to fold over it for Err or Succ(x)
result.fold(function (err) {
console.error('Server error', err);
}, function (xml) {
console.log('Post response', xml);
})
});
Ajax.put(url, contentType, responseType, credentials, _custom)
This fires a PUT request with the specified response type and content type.
Ajax.put(
'http://localhost/server/put',
ContentType.json({
'send-data': '10'
}),
ResponseType.json(),
Credentials.none(),
{ }
)).get(function (result) {
// result is a result, so you need to fold over it for Err or Succ(x)
result.fold(function (err) {
console.error('Server error', err);
}, function (val) {
console.log('Put response', val);
})
});
Ajax.del(url, responseType, credentials, _custom)
This fires a DELETE request with the specified response type.
Ajax.get(
'http://localhost/server/del/1',
ResponseType.json(),
Credentials.none(),
{ }
).get(function (result) {
// result is a result, so you need to fold over it for Err or Succ(x)
result.fold(function (err) {
console.error('Server error', err);
}, function (val) {
console.log('Delete response', val);
})
});
$ yarn test
These tests require bedrock and chrome.
FAQs
AJAX library
The npm package @ephox/jax receives a total of 1,454 weekly downloads. As such, @ephox/jax popularity was classified as popular.
We found that @ephox/jax demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.