Skip to content

Commit

Permalink
[contact] improved Ajax call
Browse files Browse the repository at this point in the history
  • Loading branch information
plegall committed Jan 29, 2018
1 parent 9ddb7ca commit e5d0fc3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions include/functions_ws_porg.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function ws_porg_contact_send($params, &$service)
/* EMAIL */
if(!filter_var($params["email"], FILTER_VALIDATE_EMAIL))
{
$error .= "<li>Whoops, invalid email format</li>";
$error .= "Whoops, invalid email format";
}
else
{
Expand Down Expand Up @@ -85,7 +85,7 @@ function ws_porg_contact_send($params, &$service)
exit;
}

echo json_encode(['code'=>404, 'msg'=>$error]);
echo json_encode(['code'=>400, 'msg'=>$error]);
exit;
}

Expand Down
11 changes: 9 additions & 2 deletions template/contact.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
$(document).ready(function() {
$('#form-submit').click(function(e) {
e.preventDefault();
if ($(this).data("state") == "push") {
if (jQuery("#form-submit").hasClass('disabled') || $(this).data("state") == "push") {
console.log("oula");
return false;
}
$(this).data("state", "push");
Expand All @@ -15,7 +17,7 @@

$.ajax({
type: "POST",
url: "ws.php",
url: "ws.php?format=json",
dataType: "json",
data: {
method: 'porg.contact.send',
Expand All @@ -31,6 +33,11 @@
$(".email-error").html("<ul class='list-unstyled' style='color: #a94442;'><li>"+data.msg+"<li></ul>");
$("#form-submit").data("state", "not-push");
}
},
error : function(data) {
console.log("[error] data.code="+data.code);
$(".email-error").html("<ul class='list-unstyled' style='color: #a94442;'><li>"+data.message+"<li></ul>");
$("#form-submit").data("state", "not-push");
}
});
});
Expand Down

0 comments on commit e5d0fc3

Please sign in to comment.