i tried to send a php array values using ajax but nothing happened and mysql table didn't update....
html:
//edit topic
if(isset($_GET['edit_topic']) && is_numeric($_GET['edit_topic']) ){
$topic_id=htmlspecialchars($_GET['edit_topic']);
$get_topic=$db->query("select * from articles where art_id='$topic_id'");
$topic=$get_topic->fetch_assoc();
?>
<form role="form" action="" id="edit_topic_form" method="post">
<div class="row">
<div class="col-md-6">عنوان الموضوع</div>
<div class="col-md-6"><input type="text" class="form-control" name="art_title" id="art_title" value="<?php echo $topic['art_title']; ?>"></div>
</div>
.........................
</form>
<?php
}
php:
if($_POST){
$topic_array=array(
"art_title"=>$_POST['art_title'],
"art_subtitle"=>$_POST['art_subtitle'],
"art_desc"=>$_POST['art_desc'],
"art_tags"=>$_POST['art_tags'],
"art_download"=>$_POST['art_download'],
"art_yt"=>$_POST['art_yt'],
"art_instructor"=>$_POST['art_instructor'],
"art_com_no"=>$_POST['art_com_no'],
"art_likes"=>$_POST['art_likes']
);
$update_topic=$db->query("update articles set
art_title='".$topic_array['art_title']."',
art_subtitle='".$topic_array['art_subtitle']."',
art_desc='".$topic_array['art_desc']."',
art_tags='".$topic_array['art_tags']."',
art_download='".$topic_array['art_download']."',
art_yt='".$topic_array['art_yt']."',
art_instructor='".$topic_array['art_instructor']."',
art_com_no='".$topic_array['art_com_no']."',
art_likes='".$topic_array['art_likes']."'
where art_id='$topic_id'
");
}
jquery:
$(document).ready(function(){
var request;
$("#edit_topic_form").submit(function(event){
if (request) {
request.abort();
}
var $form = $(this);
var $inputs = $form.find("input, select, button, textarea");
var serializedData = $form.serialize();
$inputs.prop("disabled", true);
request = $.ajax({
url: "dashboard.php",
type: "post",
data: serializedData
});
request.done(function (response, textStatus, jqXHR){
// Log a message to the console
alert("تم تعديل الموضوع بنجاح");
});
request.always(function () {
// Reenable the inputs
$inputs.prop("disabled", false);
});
event.preventDefault();
});
})