JQuery ile AJAX içinde sesli uyarı (NOTIFY) popup kullanımı
Toaster Jquery eklentisini ile sesli ajax uyari popup uygulaması
HTML
<input class="form-control" type="text" id="warning" value="" placeholder="İsim"><button class="btn btn-warning uyari">Kaydet</button> <script> (function($){ $(document).on("click",".uyari",function(){ var warning = $("#warning"); if (warning.val() !=''){ $.ajax({ type: "POST", url: "ajax.php", data: "action=warning", success: function(html){ warning.val(''); Notify('Başarıyla güncellendi', 'top-right', '5000', 'success', 'fa-check', true); return false; } }) } else { Notify('İsim alanı gerekli', 'top-right', '5000', 'danger', 'fa-times', true); return false; } }); }); </script>
uyari.js
//Notify('Başarıyla güncellendi', 'top-right', '5000', 'success', 'fa-check', true) function Notify(uyari, pozisyon, timeOut, uyarisekli, faikon, button) { toastr.options.positionClass = "toast-" + pozisyon; toastr.options.extendedTimeOut = 0; toastr.options.timeOut = timeOut; toastr.options.closeButton = button; toastr.options.iconClass = faikon + " toast-" + uyarisekli; toastr.custom(uyari) }
Hepsi bir arada
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Bilgisayar.me</title> <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"/> <script src="toaster.css"></script> <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css"/> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script> <script src="toaster.js"></script> <script src="uyari.js"></script> </head> <body> <div class="container"> <div class="row"> <div class="col-lg-4"> <div class="input-group"><div class="input-group-btn"> <input class="form-control" type="text" id="warning" value="" placeholder="İsim"><button class="btn btn-warning warning">Kaydet</button></div> </div> </div> </div> </div> <script> (function($){ $(document).on("click",".uyari",function(){ var warning = $("#warning"); if (warning.val() !=''){ $.ajax({ type: "POST", url: "ajax.php", data: "action=warning", success: function(html){ warning.val(''); Notify('Başarıyla güncellendi', 'top-right', '5000', 'success', 'fa-check', true); return false; } }) } else { Notify('İsim alanı gerekli', 'top-right', '5000', 'danger', 'fa-times', true); return false; } }); }); </script> </body> </html>