I've been creating an application that requires buttons to make an ajax call to a controller that uses autoloaded models. I was under the impression that variables in an autoloaded model would retain their values after an Ajax call, but for some reason the entire model (including their variables) have lost their new values.
Am I misunderstanding the way the autoload function works, or does it have something to do with me using Ajax?
Code for reference below.
Autoload:
$autoload['model'] = array('choice_model');
Ajax calls in JQuery:
$( document ).ready(function() {
var encounter = 1;
$.ajax({
type: "POST",
url: baseURL+"Encounter/startEncounter",
dataType: "json",
data: "encounter_id=" + encounter,
success: function(data) {
$("#message-box").html(data);
SetChoices();
}
});
});
function SetChoices() {
$.ajax({
type: "POST",
url: baseURL+"Choice/getChoices",
dataType: "json",
data: "",
success: function(data){
alert (data);
}
});
}
The first ajax call sets the following variable in Choice_model to "TestTrue":
public $test = 'TestFalse';
The second ajax call returns the previous variable, but it's value is now "TestFalse" once again.
Thank you for your time, I hope someone can help me out.