Setting global variable in Ajax change event

I have a Tab application. Tab1 is an application that calls a form with a single, double select field, displaying dates. Tab2 is a form that displays a record based on the date(s) selection in Tab1.
So, I am trying to set a global variable to be passed to Tab2 on an Ajax change event.
Here is the code on the Ajax change event, {criteria} being the field on Tab1 :
$str = “{criteria}”;
$array=explode(’;’,$str) ;
sc_set_global($array) ;

When I run the application, I can select a date, using the right arrow to move it from left column to right column. When I select a 2nd date, instead of adding the 2nd date to the right column, the first date is removed from the right column (like I’ve reloaded the page). If I remove the sc_set_global($array) line, the date selection works as intended, but of course that doesn’t do me any good as far as setting my criteria to be passed to Tab2. So, am I not allowed to set a global variable in an Ajax event?

sc_set_global() is deprecated, use [myglobalvar] instead. Then, on Application->Global Variables, set it as you need.

$str = {criteria}; // double quote is not needed.
$array=explode(';',$str) ;
[myglobal] = $array;

I get the same result with [myglobalvar]

Set the variable as session

Thank you Giu for you input. I worked on this for a couple of hours this morning and couldn’t get it to work. I took a couple of hours off, came back and just decided to recreate the simple form, and it works now…no changes from the original, so not sure why the difference.