douyalin2258 2019-03-03 14:22
浏览 63

如何在屏幕上执行JQUERY / JS,通知?

My question is this. I have a website that I am developing and I am facing the following problem that I can not solve. I make queries against mysql with php and I keep it in cookies errors or well-made queries, and I want the user on the screen to get notified that it has been completed correctly. For the notifications I am using the following js / Jquery, it is designed to run when I receive a click of a button id, but I want to execute it when this query is finished. Can you help me?

    $(document).ready(function () {

"use strict";

var i = -1;
var toastCount = 0;
var $toastlast;

var getMessage = function () {
    var msgs = ['Ejemplo de notificación'];
    i++;
    if (i === msgs.length) {
        i = 0;
    }

    return msgs[i];
};


$('#newLista_alert').click(function () {
    var shortCutFunction = 'success';
    var msg = 'Preparada para meterle canciones';
    var title = 'Lista creada existosamente' || '';
    var $showDuration = $(300);
    var $hideDuration = $(1000);
    var $timeOut = $(2000);
    var $extendedTimeOut = $(500);

    var toastIndex = toastCount++;

    var addClear = $('#addClear').prop('checked');

    toastr.options = {
        closeButton: true,
        debug: false,
        newestOnTop: false,
        progressBar: true,
        positionClass: 'toast-bottom-right' || 'toast-top-right',
        preventDuplicates: false,
        onclick: null
    };

    toastr.options.showEasing = 'swing';

    toastr.options.hideEasing = 'linear';

    toastr.options.showMethod = 'fadeIn';

    toastr.options.hideMethod = 'fadeOut';



    var $toast = toastr[shortCutFunction](msg, title); // Wire up an event handler to a button in the toast, if it exists
    $toastlast = $toast;

    if (typeof $toast === 'undefined') {
        return;
    }

    if ($toast.find('#okBtn').length) {
        $toast.delegate('#okBtn', 'click', function () {
            alert('you clicked me. i was toast #' + toastIndex + '. goodbye!');
            $toast.remove();
        });
    }
    if ($toast.find('#surpriseBtn').length) {
        $toast.delegate('#surpriseBtn', 'click', function () {
            alert('Surprise! you clicked me. i was toast #' + toastIndex + '. You could perform an action here.');
        });
    }
    if ($toast.find('.clear').length) {
        $toast.delegate('.clear', 'click', function () {
            toastr.clear($toast, { force: true });
        });
    }
});

function getLastToast() {
    return $toastlast;
}
$('#clearlasttoast').click(function () {
    toastr.clear(getLastToast());
});
$('#cleartoasts').click(function () {
    toastr.clear();
});
});

MY CODE FOR MYSQL

 <?php
session_start();
if(isset($_REQUEST['newLista'])){

$nombrelista = $_REQUEST['nombrelista'];
$usuario = $_SESSION['usuario'];

require_once "../biblioteca.php";

$db = ConectaDb($dbHost, $dbUser, $dbPass, $dbName);    

$consulta="INSERT INTO lista_musica (nombre,usuario) VALUES (:lista,:usuario)";

$result=$db->prepare($consulta);

    if ($result->execute([":lista" => $nombrelista, ":usuario" => $usuario,])){
        setcookie('result_musica','0',time()+10);
        header ('location: ../../ui-musica.php');
    }
    else{
        echo "LISTA NO SE PUDO CREAR";
    }   
}

?>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 无线电能传输系统MATLAB仿真问题
    • ¥50 如何用脚本实现输入法的热键设置
    • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
    • ¥30 深度学习,前后端连接
    • ¥15 孟德尔随机化结果不一致
    • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
    • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
    • ¥15 谁有desed数据集呀
    • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
    • ¥15 关于#hadoop#的问题