Add the option to use FormData to encode the form elements #153

Merged
BehindTheMath merged 4 commits from feature/form-data into master 2018-04-29 14:05:23 -05:00
2 changed files with 4 additions and 4 deletions
Showing only changes of commit ac0dfa7d81 - Show all commits

View File

@@ -15,8 +15,7 @@ var formAction = function(el, event) {
// Initialize requestOptions // Initialize requestOptions
options.requestOptions = { options.requestOptions = {
requestUrl: el.getAttribute("action") || window.location.href, requestUrl: el.getAttribute("action") || window.location.href,
requestMethod: el.getAttribute("method") || "GET", requestMethod: el.getAttribute("method") || "GET"
requestParams: []
} }
// create a testable virtual link of the form action // create a testable virtual link of the form action

View File

@@ -6,6 +6,7 @@ module.exports = function(location, options, callback) {
var requestOptions = options.requestOptions || {} var requestOptions = options.requestOptions || {}
var requestMethod = (requestOptions.requestMethod || "GET").toUpperCase() var requestMethod = (requestOptions.requestMethod || "GET").toUpperCase()
var requestParams = requestOptions.requestParams || null var requestParams = requestOptions.requestParams || null
var formData = requestOptions.formData || null;
var requestPayload = null var requestPayload = null
var request = new XMLHttpRequest() var request = new XMLHttpRequest()
var timeout = options.timeout || 0 var timeout = options.timeout || 0
@@ -51,8 +52,8 @@ module.exports = function(location, options, callback) {
break break
} }
} }
else if (requestOptions.formData) { else if (formData) {
requestPayload = requestOptions.formData requestPayload = formData
} }
// Add a timestamp as part of the query string if cache busting is enabled // Add a timestamp as part of the query string if cache busting is enabled