function rechercheManifest(date) { var req = new XMLHTTPRequest(); req.open("GET", "controleur/c_manifestations.php?compter=" + date); req.send(); return req.responseText; } // Et voilà, lorsque vous ferez count = rechercheManifest(date), count prendra la valeur appropriée plutot que 'undefined'.
var count = rechercheManifest(date); console.log(count);
$date = strtotime($_GET['compter']); $compter = Manifestation::compterManifestations ($date); echo json_encode($compter);
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionvar count = $.ajax({ "url": 'controleur/c_manifestations.php', "data": 'compter='+date, "type": 'GET', "dataType": 'json', "jsonpCallback": 'callback' }); console.log(count);
Object {readyState: 1, getResponseHeader: function, getAllResponseHeaders: function, setRequestHeader: function, overrideMimeType: function...}
abort: function ( statusText ) {
always: function () {
complete: function () {
done: function () {
error: function () {
fail: function () {
getAllResponseHeaders: function () {
getResponseHeader: function ( key ) {
overrideMimeType: function ( type ) {
pipe: function ( /* fnDone, fnFail, fnProgress */ ) {
progress: function () {
promise: function ( obj ) {
readyState: 4
responseJSON: 0
responseText: " 0"
setRequestHeader: function ( name, value ) {
state: function () {
status: 200
statusCode: function ( map ) {
statusText: "OK"
success: function () {
then: function ( /* fnDone, fnFail, fnProgress */ ) {
__proto__: Object
$date = strtotime($_GET['compter']); $compter = Manifestation::compterManifestations ($date); echo json_encode($compter);
$compter = Manifestation::compterManifestations ( intval($_GET['compter']) ); echo json_encode($compter);
/* Votre code original : var date = myMonth[w][d]+'-'+$('#mois').val()+'-'+$('#annee').val(); var count = rechercheManifest(date); */ // Devient : var date = new Date(); date.setDate(myMonth[w][d]); date.setMonth($('#mois').val()); date.setYear($('#annee').val()); var count = rechercheManifest(date.getTime()); // .getTime retourne le timestamp
/** * Compter les manifestations par date * * @return Nombre de manifestations */ public static function compterManifestations ($date) { global $bdd; try { $req = $bdd ->prepare("SELECT * FROM manifestations WHERE date='$date'"); $req->execute(); $manifestations = $req->fetchAll(); nouveauLog (date("Y-m-d H:i:s"), "OK", "","fonction compterManifestations"); } catch(Exception $e) { die (nouveauLog (date("Y-m-d H:i:s"), "NOK", $e->getMessage() ,"fonction compterManifestations")); } return count($manifestations); }
$compter = Manifestation::compterManifestations ( intval($_GET['compter']) ); echo json_encode($compter);
function rechercheManifest(date) { var req = new XMLHTTPRequest(); req.open("GET", "controleur/c_manifestations.php?compter=" + date); req.send(); return req.responseText; }
var date = new Date(); date.setDate(myMonth[w][d]); date.setMonth($('#mois').val()); date.setYear($('#annee').val()); var count = rechercheManifest(date.getTime()); // .getTime retourne le timestamp console.log(count);
console.log(count.responseText);
var string = 'default'; $.ajaxSetup({async: false}); $.get('controleur/c_manifestations.php?compter=" + date)', function(data){ string = data; } ); alert(string);
var date = myMonth[w][d]+'-'+$('#mois').val()+'-'+$('#annee').val();; var count; $.ajaxSetup({async: false}); $.get('controleur/c_manifestations.php?compter='+date, function(data) { count = data; } );
$date = strtotime($_GET['compter']); $compter = Manifestation::compterManifestations ($date); echo json_encode($compter);
calDateText[((7*w)+d)-7].innerText = myMonth[w][d];
for (w = 1; w < 7; w++) { for (d = 0; d < 7; d++) {
CaseEnCours.parent().css( "background-color", 'red');
var CaseEnCours = calDateText[((7*w)+d)-7]; // NE FONCTIONNE PAS
function fUpdateCal(iYear, iMonth) { myMonth = fBuildCal(iYear, iMonth); objPrevElement.bgColor = ""; document.all.calSelectedDate.value = ""; for (w = 1; w < 7; w++) { for (d = 0; d < 7; d++) { if (!isNaN(myMonth[w][d])) { var dNow = new Date(); var jourNow = dNow.getDate(); var moisNow = dNow.getMonth()+ 1; var anneeNow = dNow.getFullYear(); var date = myMonth[w][d]+'-'+$('#mois').val()+'-'+$('#annee').val(); var count; var suiteD; $.ajaxSetup({async: false}); $.get('controleur/c_manifestations.php?compter='+date, function(data) { count = data; } ); if (count>0) { var textDecoration = 'underline'; var styleBG = '#99CCF7'; } else { var textDecoration = 'none'; var styleBG = 'white'; } calDateText[((7*w)+d)-7].innerText = myMonth[w][d]; var CaseEnCours = calDateText[((7*w)+d)-7]; alert(((7*w)+d)-7); if ($('#mois').val()==moisNow && $('#annee').val()==anneeNow && jourNow==myMonth[w][d]) { calDateText[((7*w)+d)-7].style.color ='red'; } else { calDateText[((7*w)+d)-7].style.color ='#666666'; } calDateText[((7*w)+d)-7].style.textDecoration = textDecoration; //CaseEnCours.parent().css( "background-color", styleBG ); //calDateText[((7*w)+d)-7].parent().style.bgcolor = styleBG; } else { calDateText[((7*w)+d)-7].innerText = " "; } } } }