Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

215
Views
¿Cómo puedo obtener la respuesta de solo el segundo parámetro de la función view() cuando hago una solicitud GET?

Estoy haciendo una solicitud GET de ajax

 $(dataTableSearchInputButtonID).on('click', function () { $.ajax({ type: "GET", url: "myUrl.test/tools", dataType: "html", success: function (resp) { console.log(resp); }, }); });

Sin embargo, en la respuesta en la consola, solo veo el HTML al hacer clic en el botón Buscar (para recuperar y mostrar datos)

 public function getTriviaTags(Request $request){ try { $userSearch = $request->get('userSearch'); $tagsList = $this->tagRepository->getTags($userSearch); $response = [ 'tagsList' => $tagsList, 'userSearch' => $userSearch, 'trivia' => 'tag' ]; return view('pages.tools.main', $response); } catch (Exception $exception) { parent::log($exception, self::class); } }

¿Cómo puedo asegurarme de que aparezca la variable $response ( console.log(resp); ) en el método ajax success() al ingresar texto en el campo de entrada y hacer clic en Buscar?

Necesito agregar userSearch a la URL (myUrl.test/tools?userSearch="countries") para que aparezcan los datos correctos. Cuando lo hago manualmente, en la barra de búsqueda, funciona bien.

¿Estoy en el camino correcto para lograr esto?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

No debe devolver la vista, sino la respuesta JSON:

 public function getTriviaTags(Request $request){ try { $userSearch = $request->get('userSearch'); $tagsList = $this->tagRepository->getTags($userSearch); $response = [ 'tagsList' => $tagsList, 'userSearch' => $userSearch, 'trivia' => 'tag' ]; return response()->json($response) } catch (Exception $exception) { parent::log($exception, self::class); }

}

Y luego puede acceder a las variables de respuesta a través de console.log (resp.data)

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!