Using this function
function readPinMode(callback,pin){
$.ajax({
type: 'GET',
url: path,
data: {
'funct': "readPinMode", //function included and working ou of loops
'pin': pin,
'php': 0
},
success: function (result) {
//console.log(result);
callback(result);
},
error: function (xhr, textStatus, error) {
console.log(xhr);
console.log(textStatus);
console.log(error);
}
});
};
in this way, simply does not do nothing:
$( document ).ready(function() {
<?php
$js_array = json_encode($GLOBALS['gpio']); // got from included file, working
echo "var pins = ". $js_array . ";\n";
?>
console.log( "Document ready." );
for (i = 0; i < pins.length; i++) {
var mode = "m" + pins[i];
function initMode(){
readPinMode(function(ret){
console.log(ret);
$(mode).text(ret);
console.log(mode);
}, pins[i]);
};
}
It enters the for loop (I can log in console mode and pins[i], they are working) but the function seems to not be called.
Console does not show anything.
Is there a way to solve this? Thanks
retis the result of the ajax success methosfunction initMode()doing there ?? you are just defining a function. and not executing it.. as it has the logic to call AJAX and receive the resultsmodesuppose to be? is it an HTML element ID? and what arepinsexactly?