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

61
Vistas
CakePHP4: Link to Json File in Script

I have a CakePHP4 App where I create a D3JS WorldMap in a <script> tag. I need to link to a JSON File in this line d3.json("https://api.jsonbin.io/b/61f8ec14518e5f3b2ab3e218", function(error, topology) { but this time its saved in webroot folder.

I have tried to get the Path console.log('<?php echo WWW_ROOT; ?>'); but it didnt work. How can I set the Path to my file over JavaScript?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

How can I set the Path to my file over JavaScript?

path: "<?= $this->Url->build('/my.json', ['fullBase' => true]); ?> "

// Output
// path: "http://somedomain.com/my.json"

or:

<div data-json="<?= $this->Url->build('/my.json', ['fullBase' => true]); ?>" ></div>

then in your js read data attribute

Read more: https://book.cakephp.org/4/en/views/helpers/url.html

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