Commit 548f653a authored by Romain Loth's avatar Romain Loth

buttons to debug ajax doors DB write + working doors registration

parent 34052dce
......@@ -69,10 +69,22 @@
</div>
<!-- ########################### ( debg ) ########################## -->
<!-- test cgi user from submit point of view -->
<form id="test_user_form" enctype="multipart/form-data"
method="post"
action="cgi-bin/test_cgi_user.py.cgi">
<input type="submit" class="btn btn-lg btn-success" style="float:right"
id="testsubmit" value="Test user submit" />
</form>
<!-- ########################### ( FORM ) ########################## -->
<form id="comex_reg_form" enctype="multipart/form-data"
method="post"
onsubmit="whileSubmit(this)"
onsubmit="whileSubmit(this, 'from form')"
action="cgi-bin/comex_merci_pour_les_infos.py.cgi">
<!-- todo onsubmit also save to cache -->
......@@ -129,14 +141,6 @@
<input id="country" name="country" type="text" class="form-control" placeholder="pays" class="autocomp">
</div>
<p>
<button onclick='whileSubmit(this.parent.parent)'>
test doors
</button>
</p>
<!-- EMAIL & PASSWORD -->
<h3 class="formcat"> Login infos </h3>
......@@ -222,6 +226,13 @@
</form>
<p>
<button onclick='whileSubmit(this, "from button")'>
test doors
</button>
</p>
</div>
<div class="spacer col-sm-2 col-md-2">&nbsp;</div>
</div>
......
......@@ -2,19 +2,34 @@
// => block the submit button to avoid resubmit before response
// => transmit to doors
var submitButton = document.getElementById('formsubmit')
function whileSubmit(form) {
console.log(form)
submitButton.disabled = true
function whileSubmit(form, orignStr, loginOrRegister) {
console.warn("=====> CORS <=====")
console.warn("origin:", orignStr)
// submitButton.disabled = true
var action = 'register'
if (loginOrRegister && loginOrRegister == 'login') {
action = 'user'
}
console.log("form", form)
// submit to doors and wait for response
// £TEST normal case: login to doors and wait for response
$.ajax({
contentType: "application/json",
url: "http://localhost:8989/api/user",
data: {},
dataType: 'json',
url: "http://localhost:8989/api/" + action,
data: JSON.stringify({
// TODO pass the real values
"login": "jpp@om.fr",
"password": "droitaubut",
"name": "JPP"
}),
type: 'POST',
success: function(data) {
console.log("ajax success")
// console.log(data)
console.log("response data", data)
console.log("response data.id", data.id)
setTimeout(
function() {
location.reload();
......@@ -24,6 +39,8 @@ function whileSubmit(form) {
console.log("ajax error");
}
});
console.warn("=====> end of whileSubmit <=====")
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment