Skip to content

Instantly share code, notes, and snippets.

@dcneiner dcneiner/json.js Secret
Created Jun 14, 2010

Embed
What would you like to do?
// Run immediately
jQuery.getJSON('http://path.com/to/json.php?callback=?', function(html){
// Make sure DOM is ready:
jQuery(function($){
$("#footer").before(html); // Example
});
});
<?php ob_start(); ?>
<h1>Extra HTML content here</h1>
<?php
$content = ob_get_contents();
ob_end_clean();
$content = json_encode( utf8_encode( $content ) );
echo isset($_GET['callback']) ? $_GET['callback'] . '(' . $content . ');' : $content;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.