0๐
โ
As was mentioned in a comment, the state needs to be persisted.
data: {
selected: <?php echo $aid; ?>;
}
If the JS code is in another file then add a JS variable from the PHP code.
Source:stackexchange.com