Permalink
Switch branches/tags
Nothing to show
Find file Copy path
1f7ab3d Oct 18, 2016
1 contributor

Users who have contributed to this file

102 lines (67 sloc) 2.57 KB

constructor

Init the form by providing the element, it can be either HTML selector or the form element (HTMLFormElement).

Parameters

  • el (string | HTMLFormElement)
  • options [Object] Options
    • options.responseType [string] Define the response type, eg. json(default), blob, arraybuffer, leave empty if undefined
    • options.headers [Object] Define custom headers

Examples

ajaxable('form.ajaxable', {
 responseType: '',
 headers: {
   'Content-Type': 'text/html; charset=UTF-8'
 }
});

onStart

Bind a callback and execute it on start of each request The callback accepts parameters object as argument

Parameters

Examples

ajaxable('...').onStart((params) => {
 // do stuff
})

onEnd

Bind a callback and execute it on end of each request The callback accepts parameters object as argument

Parameters

Examples

ajaxable('...').onEnd((params) => {
 // do stuff
})

onResponse

Bind a callback and execute it on response of each request The callback accepts the response and parameters as arguments

Parameters

Examples

ajaxable('...').onResponse((res, params) => {
 // do stuff
})

onError

Bind a callback and execute it on error of each request The callback accepts the error and parameters as arguments

Parameters

Examples

ajaxable('...').onError((err, params) => {
 // do stuff
})

submit

Submit the request

Examples

ajaxable('...').submit();