I create a simple REST service with Slim PHP framework. You can retrive the Mayan calendar in JSON format:
Example: https://snap.apigee.com/HUN6NV or
http://almanac.alwaysdata.net/openalmanac/getMayanCalendar/
Now I would like to call it with latest JQuery Framework.
I write a very simple HTML helper:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Example!</title>
<link rel="stylesheet" href="../../css/base.css" type="text/css" media="screen" charset="utf-8"/>
<script src="http://code.jquery.com/jquery-1.7.2.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" src="script2.js"></script>
</head>
<body> etc etc....
I use http://code.jquery.com/jquery-1.7.2.js in a very simple HTML example that call this function:
$(document).ready(function(){
$.getJSON('http://almanac.alwaysdata.net/openalmanac/getMayanCalendar/',
function(data) {
alert('Fetched ' + data.length + ' items!');
});
});
But doesn’t works! I am very sad and I don’t understand what’s the problem!!
Can you help me…with a very simple code working??
Thank you for you help!!
The error I see is just in using the .lenght with the ‘data’ variable, which is not appropriate, the rest is “by the book”. See this one working: