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 @@ ...@@ -69,10 +69,22 @@
</div> </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 ) ########################## -->
<form id="comex_reg_form" enctype="multipart/form-data" <form id="comex_reg_form" enctype="multipart/form-data"
method="post" method="post"
onsubmit="whileSubmit(this)" onsubmit="whileSubmit(this, 'from form')"
action="cgi-bin/comex_merci_pour_les_infos.py.cgi"> action="cgi-bin/comex_merci_pour_les_infos.py.cgi">
<!-- todo onsubmit also save to cache --> <!-- todo onsubmit also save to cache -->
...@@ -129,14 +141,6 @@ ...@@ -129,14 +141,6 @@
<input id="country" name="country" type="text" class="form-control" placeholder="pays" class="autocomp"> <input id="country" name="country" type="text" class="form-control" placeholder="pays" class="autocomp">
</div> </div>
<p>
<button onclick='whileSubmit(this.parent.parent)'>
test doors
</button>
</p>
<!-- EMAIL & PASSWORD --> <!-- EMAIL & PASSWORD -->
<h3 class="formcat"> Login infos </h3> <h3 class="formcat"> Login infos </h3>
...@@ -222,6 +226,13 @@ ...@@ -222,6 +226,13 @@
</form> </form>
<p>
<button onclick='whileSubmit(this, "from button")'>
test doors
</button>
</p>
</div> </div>
<div class="spacer col-sm-2 col-md-2">&nbsp;</div> <div class="spacer col-sm-2 col-md-2">&nbsp;</div>
</div> </div>
......
...@@ -2,19 +2,34 @@ ...@@ -2,19 +2,34 @@
// => block the submit button to avoid resubmit before response // => block the submit button to avoid resubmit before response
// => transmit to doors // => transmit to doors
var submitButton = document.getElementById('formsubmit') var submitButton = document.getElementById('formsubmit')
function whileSubmit(form) { function whileSubmit(form, orignStr, loginOrRegister) {
console.log(form) console.warn("=====> CORS <=====")
submitButton.disabled = true 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({ $.ajax({
contentType: "application/json", contentType: "application/json",
url: "http://localhost:8989/api/user", dataType: 'json',
data: {}, url: "http://localhost:8989/api/" + action,
data: JSON.stringify({
// TODO pass the real values
"login": "jpp@om.fr",
"password": "droitaubut",
"name": "JPP"
}),
type: 'POST', type: 'POST',
success: function(data) { success: function(data) {
console.log("ajax success") console.log("ajax success")
// console.log(data) console.log("response data", data)
console.log("response data.id", data.id)
setTimeout( setTimeout(
function() { function() {
location.reload(); location.reload();
...@@ -24,6 +39,8 @@ function whileSubmit(form) { ...@@ -24,6 +39,8 @@ function whileSubmit(form) {
console.log("ajax error"); 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