Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

196
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda