Update database data without updating page [closed]

1

I have a question: I want to update the data that is seen in my php web that is connected to a database and that what changes in the database is updated on the web without updating. I know it's done with "Ajax" but the only tutorials I found are with forms, and I do not adapt it or it does not work for me.

Here I leave what I want to be applied: Cool the "match1" without updating the page (This is all in PHP)

    else if ($quediaes=="Wed" && 11 <= $hora && $hora <= 12) {
        echo '<h3>Estás mirando: ' . $rows_dbpartidos['partido1'] . '</h3>';
    }
    
asked by MatiPHP 30.06.2018 в 05:11
source

1 answer

-2

As you have been told, there is still a lot of information missing, for example if you use forms and datatables or tables to see the records in your database, the question is more than doubts because it shows that you have certain doubts to carry out your work.

The next block of code I leave it but even if you do not explain very well in detail that you are using so that the changes made to your database are reflected in the browser without reloading the web page will leave you lost.

$(document).ready(function() {
  $('.btn_registrar_trabajo_domestico_1').click(function(){

        //Obtenemos el valor del campo escuela
        var txt_var_numerador_resumen = $(".txt_var_numerador_resumen").val();
        //Validamos el campo escuela, simplemente miramos que no esté vacío
        if (txt_var_numerador_resumen == "") {
            alertify.error('No deje el campo #1 vacio');
            $(".txt_var_numerador_resumen").focus();
            return false;
        }
        
        var txt_var_denominador_resumen = $(".txt_var_denominador_resumen").val();
        //Validamos el campo escuela, simplemente miramos que no esté vacío
        if (txt_var_denominador_resumen == "") {
            alertify.error('No deje el campo #2 vacio');
            $(".txt_var_denominador_resumen").focus();
            return false;
        }

        var id_anio_trabajo_domestico_1 = $(".id_anio_trabajo_domestico_1").val();
        if (id_anio_trabajo_domestico_1 == "0") {
            alertify.error('Seleccione un año');
            $(".id_anio_trabajo_domestico_1").focus();
            return false;
        }

        var id_dept_trabajo_domestico_1 = $(".id_dept_trabajo_domestico_1").val();
        if (id_dept_trabajo_domestico_1 == "0") {
            alertify.error('Seleccione un departamento');
            $(".id_dept_trabajo_domestico_1").focus();
            return false;
        }

        var sexo_trabajo_domestico_1 = $(".sexo_trabajo_domestico_1").val();
        if (sexo_trabajo_domestico_1 == "0") {
            alertify.error('Seleccione el sexo');
            $(".sexo_trabajo_domestico_1").focus();
            return false;
        }

        //Creamos la Variable que recibira el "Value" de todos los Input que esten dentro del Form
        var obtener = $("#form_trabajo_domestico_1").serialize();

        $.ajax({
            type: "POST",
            url: "php_registrar_datos/trabajo_domestico_1_php/insertar_bd_trabajo_domestico_1.php",
            data: obtener,
            cache: false,
            success: function(respuesta) {
/*                if (respuesta==1) {*/
                    alertify.success('Registro Exitoso!'); //Mensaje de Datos Correctamente Insertados
                    $('#contenedor').load("formularios_indicadores/form_trabajo_domestico_1.php"); //Recargamos la Tabla(Para que se muestren los Nuevos Resultados)
                    $(".txt_var_numerador_resumen").val(""); //Limpiamos los Input
                    $('.txt_var_denominador_resumen').val(""); //Limpiamos los Input
/*                }
                else{
                    alertify.minimalDialog || alertify.dialog('minimalDialog',function(){
                        return {
                            main:function(content){
                                this.setContent(content); 
                            }
                        };
                    });*/
/*                    alertify.minimalDialog("El año que intenta ingresar, ya ha sido registrado.");
                    //alertify.alert("El año que intenta ingresar, ya ha sido registrado.");
                    $('#contenedor').load("formularios_indicadores/form_trabajo_domestico_1.php"); //Recargamos la Tabla(Para que se muestren los Nuevos Resultados)
                    $(".txt_var_numerador_resumen").val(""); //Limpiamos los Input
                    $(".txt_var_denominador_resumen").val("");
                }*/
            }
        }); //Terminamos la Funcion Ajax
        return false; //Agregamos el Return para que no Recargue la Pagina al Enviar el Formulario  
    }); //Terminamos la Funcion Click
}); //Terminamos la Funcion Ready
    
answered by 30.06.2018 в 08:08