Skip to content

Commit

Permalink
javascript added to handle ajax request for setup
Browse files Browse the repository at this point in the history
  • Loading branch information
0c34 committed Nov 6, 2017
1 parent 977dc72 commit 6df407f
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions templates/template.setup.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
make sure to correct the mysql credentials in /config/config.json
</p>

<form method="post">
<input type="submit" class="btn btn-primary" value="Create / Reset">
<input type="hidden" name="action" value="cr">
<form id="myform">
<input type="hidden" name="act" value="cr">
<button type="button" class="btn btn-primary" id="action">Create / Reset</button>
</form>
<br>
{{.error}}

<div class="msg-area" style="width:350px"></div>
</div>
</div>
</div>
Expand All @@ -27,5 +27,31 @@
$(document).ready(function(){
$("#info").delay(3000).fadeOut();
});

function pushAlert(message, cssClass){
var html = '';
html += '<div class="alert '+cssClass+' alert-dismissable">';
html += '<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a> ';
html += message+'</div>';
return html

}
$("#action").on('click',function(){
var data = $("#myform").serialize();
var url = "{{.weburl}}setupaction";
var cssclass = "alert-success";

$.post(url, data)
.done(function(res){
$.each(res[0],function(key, value){
if (value.Status == "0"){
cssclass = "alert-danger";
}
html = pushAlert(value.message, cssclass);
$(".msg-area").append(html)
})
})
})

</script>
{{template "template.footer"}} {{ end }}

0 comments on commit 6df407f

Please sign in to comment.