When calling a function (Uncaught ReferenceError Is not defined) [closed]

0

I have a problem when I call the show products by quality and specialty () . Before I had only the first two parameters, but when I added the third data.name I got the following error:

Uncaught ReferenceError: MADRID is not defined     at: 1: 52 This function collects the parameters:

function mostrarproductosporlocalidadyespecialidad(id_localid, cat, nombrePoblacion)

These values would be picking up the function: show products by quality and specialty (29077,45, MADRID)

Can you throw some light on me, please?

$.ajax({
        data: params,
        url: 'adminasesmed/obtenerlugares.php',
        type: 'post',
        dataType: 'json',
        success: function(response){
            var cat;
            cat = getUrlVars();
            var data;   
            /*Liampiamos el div antes de ejecutar otra busqueda*/
            $("#localidades").html("");     
            /*Volvemos a llenar el div*/                        
            var html =  "<ul style=''>";
            $.each(response, function(index, data){                                                                                                     
                html += "<li><a style='display: block;color: #000;padding: 8px 16px;text-decoration: none; :hover background-color: #555;color: white' href='javascript:mostrarproductosporlocalidadyespecialidad(" + data.id_localidad + "," + cat + "," + data.nombre + ")'>" + data.nombre + " - (" + data.codigoProvinciaAsesmed + ")</a><li>";
                console.log(html);
            });
            html += "</ul>"
            $("#localidades").append(html);                             
        }
    })
    
asked by jandresplp 20.07.2017 в 17:17
source

1 answer

1

As is your code, MADRID takes it as a variable that bears the name MADRID, if you want it to take the string MADRID write it as such, so "MADRID" so the parameter is a value and not an undefined variable .

    
answered by 20.07.2017 в 19:06