5
Ajax kullanarak form verilerini göndermeye çalışıyorum. Ama ajax işleminde bir hata var ve sadece "hata" geri arama işlevi yürütülür. İşte denedim ne: Ben eklendi AyrıcaAJAX çağrısı beklendiği gibi çalışmıyor
$f3->route('POST /itprocurement/save', 'GBD\Internals\Controllers\ITProcurementController->save');
toplam:
$("#issue_submit").click(function (e) {
console.log("clicked on the issue submit");
e.preventDefault();
// Validate the form
var procurementForm = $("#it_procuremet_form");
if($(procurementForm).valid()===false){
return false;
}
// Show ajax loader
appendData();
var formData = $(procurementForm).serialize();
// Send request to save the records through ajax
var formRequest = $.ajax({
url: app.baseurl("itprocurement/save"),
data: formData,
type: "POST",
dataType: "json"
});
formRequest.done(function (res) {
console.log(res);
});
formRequest.error(function (res, err) {
console.log(res);
});
formRequest.always(function() {
$("#overlay-procurement").remove();
// do somethings that always needs to occur regardless of error or success
});
});
Rotalar tanımlanır
$f3->route('POST /itprocurement/save [ajax]', 'GBD\Internals\Controllers\ITProcurementController->save');
Ben kontrolör sınıfında ajax arama için basit bir dize dönen çalıştı
. ITProcurementController.php
:
public function save($f3)
{
echo 'Problem!';
return;
$post = $f3->get('POST');
}
Ama sadece 'hatası' geri arama yürütülür. Yanlış olanı bulamıyorum. Lütfen yardım et.
İstekte bulunduğunuzda, chrome veya firefox'taki geliştirici araçlarında ağ sekmesini açın ve hangi yanıtı aldığınızı bize bildirin. – Chris