Skip to content

Instantly share code, notes, and snippets.

Created September 14, 2015 09:41
Show Gist options
  • Save anonymous/d87109f28481ce6c6f39 to your computer and use it in GitHub Desktop.
Save anonymous/d87109f28481ce6c6f39 to your computer and use it in GitHub Desktop.
<?php
$pdo=new PDO("mysql:dbname=markers;host=127.0.0.1","root","");
$stmt = $pdo->query("SELECT * FROM markers");
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo json_encode($results);
?>
<script id="source" language="javascript" type="text/javascript">
$(function(){
$.ajax({
url: 'test.php',
data: "",
dataType: 'json',
success: function(data)
{
//alert(data[2].desc);
console.log(data[2].desc);
}
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment