Using the code in the console it works.
My data.php file in the js/data.php is
[php]<?php
header(‘Content-Type: application/json’);
include ‘config.php’;
$query = mysql_query(“SELECT str_data ,occasione FROM Evento”);
$arraydata = array();
$arraynome = array();
while($row = mysql_fetch_assoc($query)){
$arraydata[] = date(“m-d-Y”, $row[‘str_data’]);
$arraynome[] = $row[‘occasione’];
}
$datanome = array_combine($arraydata, $arraynome);
// Output it as JSON
echo json_encode($datanome);
?> [/php]
Maybe the problem is how i implement the script
[php] $.get(“js/data.php”)
.done(function(data) {
$("#calendar").calendario().setData(data)
})
.fail(function() {
console.log(‘failed’)
});[/php]
into my index2.html ?
[php]$(function() {
var transEndEventNames = {
'WebkitTransition' : 'webkitTransitionEnd',
'MozTransition' : 'transitionend',
'OTransition' : 'oTransitionEnd',
'msTransition' : 'MSTransitionEnd',
'transition' : 'transitionend'
},
transEndEventName = transEndEventNames[ Modernizr.prefixed( 'transition' ) ],
$wrapper = $( '#custom-inner' ),
$calendar = $( '#calendar' ),
cal = $calendar.calendario( {
onDayClick : function( $el, $contentEl, dateProperties ) {
if( $contentEl.length > 0 ) {
showEvents( $contentEl, dateProperties );
}
},
caldata: function() {
$.get("js/data.php")
.done(function(data) {
$calendar.setData(data);
})
.fail(function() {
console.log('failed')
});
return [];
},
displayWeekAbbr : true
} ),
$month = $( '#custom-month' ).html( cal.getMonthName() ),
$year = $( '#custom-year' ).html( cal.getYear() );
$( '#custom-next' ).on( 'click', function() {
cal.gotoNextMonth( updateMonthYear );
} );
$( '#custom-prev' ).on( 'click', function() {
cal.gotoPreviousMonth( updateMonthYear );
} );
function updateMonthYear() {
$month.html( cal.getMonthName() );
$year.html( cal.getYear() );
}
// just an example..
function showEvents( $contentEl, dateProperties ) {
hideEvents();
var $events = $( '<div id="custom-content-reveal" class="custom-content-reveal"><h4>Events for ' + dateProperties.monthname + ' ' + dateProperties.day + ', ' + dateProperties.year + '</h4></div>' ),
$close = $( '<span class="custom-content-close"></span>' ).on( 'click', hideEvents );
$events.append( $contentEl.html() , $close ).insertAfter( $wrapper );
setTimeout( function() {
$events.css( 'top', '0%' );
}, 25 );
}
function hideEvents() {
var $events = $( '#custom-content-reveal' );
if( $events.length > 0 ) {
$events.css( 'top', '100%' );
Modernizr.csstransitions ? $events.on( transEndEventName, function() { $( this ).remove(); } ) : $events.remove();
}
}
});[/php]
The strange thing is that if i include this
[php][/php]
In my index2.html page, the F12 > Network load the data.php file. If i delete that code the browser doesn’t read the data.php file anymore.