Skip to content
This repository has been archived by the owner on Jul 3, 2024. It is now read-only.

Commit

Permalink
adding staticman dev submission logic per eduardoboucas/staticman#243…
Browse files Browse the repository at this point in the history
  • Loading branch information
simonarnell committed Jan 13, 2019
1 parent 73ebe95 commit 7eb2cac
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions resources/js/survey.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ $(document).ready(function() {
})

function sendDataToServer(survey) {
var resultAsString = JSON.stringify(survey.data);
alert(resultAsString); //send Ajax request to your web server.
var formdata = new FormData();
Object.keys(survey.data).forEach(function(key) {
if (key != "question9")
formdata.append("fields[" + key + "]", survey.data[key].toString())
else {
Object.keys(survey.data[key]).forEach(function(index) {
var letter = String.fromCharCode(97 + (index - 1))
formdata.append("fields[" + key + letter + "]", survey.data[key][index].toString())
})
}
})
var data = new URLSearchParams(formdata);
fetch("https://dev.staticman.net/v2/entry/simonarnell/GDPRDPIAT/staticman/", {
method: "POST",
body: data
})
}

0 comments on commit 7eb2cac

Please sign in to comment.