Skip to content
Snippets Groups Projects
Commit 0cf0425e authored by Sofiane Lasri's avatar Sofiane Lasri
Browse files

isJson

parent a2665c5d
Branches
No related tags found
No related merge requests found
......@@ -310,6 +310,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['recaptcha_response'])
$.post( "/backTasks/?handleLoginAndRegisterForm", $( "#registerForm" ).serialize() )
.done(function( data ) {
console.log(data);
if(isJson(data)){
let json = JSON.parse(data);
if(json.success){
SnackBar({
......@@ -323,8 +324,24 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['recaptcha_response'])
timeout: false
});
}
}else{
SnackBar({
message: data,
status: "danger",
timeout: false
});
}
});
}
function isJson(str) {
try {
JSON.parse(str);
} catch (e) {
return false;
}
return true;
}
</script>
</body>
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment