add ajax to lost form
This commit is contained in:
parent
f949d07115
commit
df470b370f
4 changed files with 93 additions and 25 deletions
|
@ -16,10 +16,15 @@
|
|||
<li class="breadcrumb-item active">Feature Request</li>
|
||||
</ol>
|
||||
|
||||
<div class="alert alert-danger" role="alert">
|
||||
<div id="alertmessage" class="collapse alert alert-danger" role="alert">
|
||||
This is a danger alert—check it out!
|
||||
</div>
|
||||
|
||||
|
||||
<div id="successmessage" class="collapse alert alert-success" role="alert">
|
||||
A simple success alert—check it out!
|
||||
</div>
|
||||
|
||||
<!-- Area Chart Example-->
|
||||
<div class="card mb-3">
|
||||
<div class="card-header">
|
||||
|
@ -27,7 +32,7 @@
|
|||
Add Feature Request
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form id="lost_form" method="POST" action="action.php?action=lost">
|
||||
<form id="request_form" method="POST" action="/action.php?action=lost">
|
||||
<div class="form-group">
|
||||
<label for="title_field">Title</label>
|
||||
<input type="text" class="form-control" placeholder="title" name="title" id="title_field">
|
||||
|
@ -50,17 +55,20 @@
|
|||
<script>
|
||||
|
||||
function testajax(){
|
||||
$.post( "ajax.php?action=add_lost", $( "#lost_form" ).serialize() ).done(function( data ) {
|
||||
alert( "Data Loaded: " + data );
|
||||
$.post( "/ajax.php?action=add_featurerequest", $( "#request_form" ).serialize() ).done(function( data ) {;
|
||||
reply = JSON.parse(data);
|
||||
if(reply.status == "ok"){
|
||||
$( "#lost_form" ).trigger("reset");
|
||||
$("#alertmessage").collapse('hide');
|
||||
$("#successmessage").html(reply.message).collapse('show');
|
||||
}else{
|
||||
$("#successmessage").collapse('hide');
|
||||
$("#alertmessage").html(reply.message).collapse('show');
|
||||
}
|
||||
}).fail(function() {
|
||||
alert( "error" );
|
||||
}).always(function() {
|
||||
alert( "finished" );
|
||||
});;
|
||||
|
||||
/*$.post( "ajax.php", { name: "John", time: "2pm" } ).done(function( data ) {
|
||||
alert( "Data Loaded: " + data );
|
||||
});*/
|
||||
$("#successmessage").collapse('hide');
|
||||
$("#alertmessage").html("error").collapse('show');
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue