image upload using jquery ajax when form submit php
<td><button type="button" class="send_notification" onclick="sendNotification(<?php echo $row['patient_id']; ?>)">SEND</button></td>
function sendNotification(patient_id)
{
$('#modal-content').on('shown.bs.modal', function () {
$("#message").focus();
});
$('#modal-content').modal({
show: true
});
$('.notification_submit').click(function(event){
event.preventDefault();
var message= $('#message').val();
var file_data = $("#file").prop("files")[0]; // Getting the properties of file from file field
var form_data = new FormData(); // Creating object of FormData class
form_data.append("file", file_data) // Appending parameter named file with properties of file_field to form_data
form_data.append("Messsage", message)
form_data.append("Patient_Id", patient_id)
$.ajax({
url:'single_patient_notification.php',
cache: false,
contentType: false,
processData: false,
data: form_data, // Setting the data attribute of ajax with file_data
type: 'post',
success: function(data){
$('#modal-content').css('display','none');
alert(data);
location.reload();
}
})
});
}
function sendNotification(patient_id)
{
$('#modal-content').on('shown.bs.modal', function () {
$("#message").focus();
});
$('#modal-content').modal({
show: true
});
$('.notification_submit').click(function(event){
event.preventDefault();
var message= $('#message').val();
var file_data = $("#file").prop("files")[0]; // Getting the properties of file from file field
var form_data = new FormData(); // Creating object of FormData class
form_data.append("file", file_data) // Appending parameter named file with properties of file_field to form_data
form_data.append("Messsage", message)
form_data.append("Patient_Id", patient_id)
$.ajax({
url:'single_patient_notification.php',
cache: false,
contentType: false,
processData: false,
data: form_data, // Setting the data attribute of ajax with file_data
type: 'post',
success: function(data){
$('#modal-content').css('display','none');
alert(data);
location.reload();
}
})
});
}
Comments
Post a Comment