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

63
Views
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 answers
Answer question

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 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!