Merhaba arkadaşlar,
Post işleminde bir sıkıntım var. Tam olarak çözemedim.
Sorunum şu:
Bir selectbox seçimine göre textareaya metin çekiyorum.
Send dediğimde formdaki veriler geliyor. Sadece textarea gelmiyor.
Hiç bir değişiklik yapmadan tekrardan post ediyorum. Bu sefer textareadaki data dahil hepsi geliyor.
Bu neyden kaynaklanır?
Kodlarım:
Formum:
<form id="sendSupplierEmail">
<div class="form-group row">
<label for="staticEmail" class="col-sm-2 col-form-label">Select Template</label>
<div class="col-sm-12">
<select name="supplier_id" id="template" style="font-size: 14px!important;" class="form-controls selectpicker" data-live-search="true" >
<option value="">Select Template</option>
<?php $sql=$db->qSql("SELECT * FROM mail_template");
$getTemplate=$sql->fetchAll(PDO::FETCH_ASSOC);
foreach ($getTemplate as $template) { ?>
<option value="<?php echo $template['id'] ?>"><span><?php echo $template['name'] ?></span></option>
<?php } ?>
</select>
</div>
</div>
<textarea name="description" id="editor1" cols="30" rows="10"></textarea>
<input type="hidden" name="id" value="<?php echo $getData['id'] ?>"></input>
<input type="hidden" name="sendSupplierEmails" value="1"></input>
<div class="pt-4">
<button class="btn btn-success btn-block">Submit to Collect Offer</button>
</div>
</form><script>
$(document).ready(function(e) {
$("#sendSupplierEmail").on('submit',(function(e){
$.ajax({
url:'process.php',
type:'POST',
data:new FormData(this),
contentType:false,
cache:false,
processData:false,
success: function(result) {
if($.trim(result) == "sameEmailTemplate") {
Swal.fire({
icon: 'error',
title: 'Oops...',
text: 'This email template has already been added.',
});
}
if($.trim(result) == "ok") {
Swal.fire({
icon: 'success',
title: 'Success',
text: 'Email sent to suppliers.',
});
}
}
});
return false;
}));
});
</script>