ax1 / iridiumjs

🚀 Boost HTML horsepower
MIT License
1 stars 0 forks source link

add again ajaxform functionality #16

Open ax1 opened 6 years ago

ax1 commented 6 years ago

Was removed before to clean theAPI buuuuut:

it is still useful when classic-form functionalities are used.

The execution will be everything in one line ajaxForm(form).then().catch()

Currently urlencoded header formdata and method post must be set. Whit ajaxform none is needed

The only caveat is when headers are required so implement the optional "{options}" method as well, to allow adding headers (tokens, etc)

ajaxForm(form[,options]).then().catch()

will replace

var formData = new FormData(form)
const headers = new Headers()
headers.set('content-type', 'application/x-www-form-urlencoded')
const data = `user=${user}&password=${password}`
ir.ajax(form.action, { method: 'POST', headers , body: data }).then().catch()