samedi 31 mai 2014

ajax sending data conflict


Vote count:

0




hello i have two forms in my html code and i send data to two different php files but something is wrong,when i submit a button he send data to second php file. hello i have two forms in my html code and i send data to two different php files but something is wrong,when i submit a button he send data to second php file. hello i have two forms in my html code and i send data to two different php files but something is wrong,when i submit a button he send data to second php file.



<form id="comment" method="post" action="comment.php" role="form">
<input type="hidden" name="id" value="<?php echo $rows['id']; ?>">
<textarea name="comment" class="form-control" rows="3"></textarea>
<div style="padding:10px 0 25px 0">
<button type="submit" class="pull-right btn btn-default">Post Comment</button></div>
</form>

<script type="text/javascript">
var frm = $('#comment');
frm.submit(function (ev) {
$.ajax({
type: frm.attr('method'),
url: frm.attr('action'),
data: frm.serialize(),
success: function (data) {
new PNotify({
title: 'Comment posted.',
text: 'Back to tasks list in 3 seconds..',
type: 'success'
});
setTimeout(function(){window.location.reload()}, 3000);
}
});
ev.preventDefault();
});
</script>


<form id="editticket" method="post" action="edit-ticket.php" role="form">
<input type="hidden" name="id" value="<?php echo $id; ?>" >
<div class="form-group">
<label>Change Name</label>
<input name="name" class="form-control" value="<?php echo $rows['name']; ?>" placeholder="">
</div>
<div class="form-group">
<label>Add user</label>
<input name="users" class="form-control" placeholder="write name">
</div>
<button type="submit" onclick="tinyMCE.triggerSave();"class="btn btn-default">Save changes</button>
</form>

<script type="text/javascript">
var frm = $('#editticket');
frm.submit(function (ev) {
$.ajax({
type: frm.attr('method'),
url: frm.attr('action'),
data: frm.serialize(),
success: function (data) {
new PNotify({
title: 'Task edited.',
text: 'Back to tasks list in 3 seconds..',
type: 'success'
});
setTimeout(function(){window.history.back()}, 3000);
}
});
ev.preventDefault();
});
</script>

editticket.php
<?php
include_once 'include/functions.php';
secureSession();
editTicket($mysqli,$id);
?>

comment.php
<?php
include_once 'include/db_connect.php';
include_once 'include/functions.php';
secureSession();
$id = $_POST['id'];
comment($mysqli,$id);
?>


asked 52 secs ago






Aucun commentaire:

Enregistrer un commentaire