Question
Other alternative to xmlhttp
Hi everyone,
I have a file.txt that is written with json rules. Into my project I want to access the data of the file like a simply array.
Is there other way to open this txt file?
My code is the following one:
var xmlhttp = new XMLHttpRequest(); //apertura del file sequenze
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
myObj = JSON.parse(this.responseText)
console.log(myObj.repair_sequence) // repair_sequence è il nome dell'oggetto indicato nel file .txt formattato con grammatica json
$scope.updateLabel = function(){ //parameter viene passato quando si seleziona la lingua nei rispettivi pulsanti
console.log("----STEP STARTED----")
$scope.$on("stepcompleted", function () { //questa chiamata attende il completamento del passo prima di azzerare la stringa "text"
console.log("----STEP COMPLETED----")
text=""
$scope.setWidgetProp( "stepDescription", "text", text) //step-description è il nome della label in cui di vanno a stampare le indicazioni dei passi
});
$scope.$on('stepstarted', function() {
var currentStep = $scope.app.view.Maintenance.wdg[nomeVista].currentStep //nomeVista corrisponde al nome della vista creata nel canvas
console.log(currentStep)
var repair_selection = $scope.getWidgetProp(nomeVista, 'sequence')
if(repair_selection == sequence_1)
sequence_type=0
else if(repair_selection == sequence_2)
sequence_type=1
else
console.log("Error!!!")
// stampa descrizione sequenza di manutenzione
// traino[0]: italiano
//traino[1]: inglese
text = myObj.repair_sequence[sequence_type].traino[0].description[currentStep-1];
$scope.setWidgetProp( "stepDescription", "text", text)
});
}
}
};

