Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

192
Vistas
Why do I have the error of "Undefined variable: req"?

I want to display a map of the search. But I keep getting "undefined variable: req" notification. What should I change from my following code:

var jQuery_1_8_2 = jQuery.noConflict();
    $(function () {
        var array = JSON.parse('{!! !empty($total_search_query) ? json_encode($total_search_query) : "[]" !!}');
        console.log(array);
        $('#map2').vectorMap({
            map: 'indonesia-adm1_merc',
            backgroundColor: '#ADF3F0',
            regionStyle: {
                initial: {
                    fill: '#FFFFFF'
                },
                hover: {
                    fill: '#175083'
                }
            },
            zoomButtons: false,
            zoomOnScroll: false,
            zoomOnClick: false,
            zoomMax: 1,
            normalizeFunction: 'polynomial',
            onRegionClick: function (event, code) {
                var url = '{{ route("search", ["q" => $req->input("q"), "province" => ":id"]) }}';
                url = url.replace("%3Aid", code.toLowerCase());
                window.location.href = url;
            },
            onRegionTipShow: function (event, label, code) {
                var map = $('#map2').vectorMap('get', 'mapObject');
                var regionName = map.getRegionName(code);
                var a = array.find(a => a.name === myTrim(regionName))['count'];
                
                label.html('<div class="map-tooltip"><h4 class="header">' + regionName + '</h4><p class="description">Total: ' + a + '</p></div>');
            }
        });
    }(jQuery_1_8_2));
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The problem is with the $req->input("q") part that you can determine via looking at the error message which complains about $req not being defined. The reason is that in your Laravel code at some place you have stored the result of request() into a variable called $req, which does not exist in this context. This is the view part, while you have probably parsed the result of request() in your controller. As a result you will need

request()->input("q")

instead.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda