/ Published in: PHP
Use PHP to get JSON
1) set the PHP to the URL of the JSON
2) echo a variable with the loaded data
3) use a request via jQuery to get the variable from PHP
1) set the PHP to the URL of the JSON
2) echo a variable with the loaded data
3) use a request via jQuery to get the variable from PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/* PHP FILE - names 'example.php' */ <?php echo $content; ?> /* jQuery making the request */ $.getJSON('example.php', function(data){ var items = []; $.each(data, function(key, val){ // do stuff with data log('key: ' + key + '. value: ' + val); }); });