error ajax function

0

I have this code in a php file:

<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<?php
    //Tabla inicial sin parámetros de búsqueda
    require('conexionbd.php');

    $general = 'SELECT * FROM pedidos';
    $result = mysql_query($general) or die('Consulta fallida: ' . mysql_error());

    echo "<table class='table table-striped table-pedidos-g'>\n";
    echo "<tr class='superior'>
            <td>Nº pedido</td>
            <td>Fecha</td>
            <td>Descuento</td>
            <td>Cliente</td>
            <td>Estado</td>
        </tr>";

    while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
        echo "\t<tr>\n";
        foreach ($line as $col_value) {
            echo "\t\t<td>$col_value</td>\n";
        }
        echo "\t</tr>\n";
    }
    echo "</table>\n";

    // Liberar resultados
    mysql_free_result($result);

    // Cerrar la conexión
    mysql_close($link);
?>

<script>
    $('#buttonFechaPedido').click(function() {
        $('.table-pedidos-g').hide();
        $('.table-pedidos-n').hide();
        $('.table-pedidos-e').hide();
        var valorFecha = $('#inputFechaPedido').text();
        if (valorFecha.length == 0){
            $('#emptyFecha').removeClass('mistake');
        }
        else{
            $.ajax({
                data:  valorFecha,
                url:   'pedidos/pfechas.php',
                type:  'post',
                beforeSend: function () {
                    $("#tablaPedido").html("Procesando, espere por favor...");
                },
                error:function (){
                    $('#errorFecha').removeClass('mistake');
                },
                success:  function (response) {
                    $("#tablaPedido").html(response);
                }
            });
        }       
    });
</script>

And you are generating the following error in the console: Uncaught TypeError: $ .ajax is not a function

    
asked by auremanci 16.11.2017 в 18:18
source

1 answer

4

The jQuery-slim version does not support Ajax: documentation

You should use: link

    
answered by 16.11.2017 в 18:27