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

128
Views
No se puede enviar un json grande para la respuesta de AJAX desde PHP

Intento obtener una gran cantidad de datos de mongoDB, pero volvió roto en el medio, como [item, item, ite . Cuando solicito datos más pequeños, todo está bien. Código en el archivo php:

 if ($location) { //define cursor $rest = $collection->find(['borough' => $location]); //make array of restaurants names foreach ($rest as $restaurant) { if ($restaurant['name'] != '') { $array[] = $restaurant['name']; } } //forming response if ($array) { echo json_encode( $array, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP ); } else { http_response_code(204); } exit(); }

Obteniendo " SyntaxError: token inesperado en JSON en la posición 65528 " cuando lo analizo en JS, y siempre en la misma posición sin importar qué datos sean. Este es probablemente un problema de php, porque si JSON hace desde $array=range(1,1000000) doy el mismo resultado. ¿Alguna idea?

upd: lo siento, copié la sección incorrecta del código. Editado.

over 4 years ago · Santiago Trujillo
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!