Ajax example dependent dropdown callback
The issue was fixed by changing one of the fields in the Content Type to List(text) instead of node reference. After this the "Illegal choice error" disappeared.