Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
ajax-manager
Advanced tools
A jQuery ajax management tool
npm install ajax-manager
import ajaxManager from 'ajax-manager'
ajaxManager(models, globalConfig, jQuery)
ajaxManager()
Use ajaxManager()
to register all your backend apis. It recieve there arguments:
models
: Array
, required, each of the element is an object contains a bounch of backend apisglobalConfig
: Object
, required, all the config set here will effect all the backend api callingjquery
: jQuery
, required, give me your jQuery! import ajaxManager from 'ajax-manager'
import $ from 'jquery'
var userModels = {
getUserInfoById: {
// you can set any config that allowed in $.ajax() here
methods: 'GET',
url: 'http://127.0.0.1/get_user_info_by_id'
},
getUsers: {
methods: 'GET',
url: 'http://127.0.0.1/get_users'
},
register: {
methods: 'POST',
contentType: 'application/json'
url: 'http://127.0.0.1/register'
}
}
var globalConfig = {
// you can set any config that allowed in $.ajax() here
beforeSend () {
console.log('ajax fire!')
}
}
var apis = ajaxManager([userModels], globalConfig, $)
API()
When apis register is done, the key of each api will be registered as a function of the returning object, and you can exce it to trigger ajax. It recieved 3 arguments:
config
: Object
, required, ajax config,triggerAjaxStartAndStop
: Boolean
, indicates if the ajax trigger start and stop eventtriggerGlobalEvents
: Boolean
, indicates if the ajax trigger global eventsThis function return an jquery ajax object so it can call done()
, fail()
, always()
function chainly.
apis.getUserInfoById({
// you can set any config that allowed in $.ajax() here
data: {
id: 1
},
success (data, textStatus, qXHR) {
console.log(success)
},
error (jqXHR, textStatus, errorThrown) {
console.log(fail)
}
}, )
.done((data, textStatus, jqXHR) => {})
.fail((jqXHR, textStatus, errorThrown) => {})
.always((data|jqXHR, textStatus, jqXHR|errorThrown) => {})
You can write config in both model difinition config, ajaxManager(m, globalConfig, j)
and API(config)
.You can find all the accepted config in jQuery.ajax. All the config will be merged in one object just like Object.assign(ajaxManagerConfig, modelDifinitionConfig, apiCallingConfig)
except events.
There are 3 kinds of events
beforeSend
success
error
complete
ajaxStart
ajaxStop
beforeSend
success
error
complete
Global events only sopported in ajaxManager()
config, those events will triggered by every ajax firing unless it set triggerGlobalEvents
to false
.
Start and stop events only sopported in ajaxManager()
config, this tow events only triggered when all the ajax start and all stoped(Just like $( document ).ajaxStart()
and $( document ).ajaxStop
).
Local events supported in model definition config and API()
config. The same event set in both model definition config and API()
config will only triggered one(the API()
config local event)
FAQs
An jQuery ajax management tool
The npm package ajax-manager receives a total of 1 weekly downloads. As such, ajax-manager popularity was classified as not popular.
We found that ajax-manager 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.