Electrolysis is a method of decomposition of ionic compounds into their elements, in which a chemical substance is either in its aqueous state or in its molten state, it takes place when an electric current is passed through them.
The electrode at which the oxidation process occurs and it is positively charged electrode is known as the anode whereas the electrode at which the reduction process takes place and is negatively charged electrode is known as the cathode.
In solid Sodium chloride, ions are present but these ions are locked into their ionic lattice and are not able to move. (common salt) is solid in a state and doesn't conduct electricity. For the flow of electricity, it should either be melted, molten, or dissolved in a solution (i.e. water) first. Then only the electrons will be free to move either towards the cathode or to the anode. In a liquid state, the electrons are free to move anywhere easily.