Yes, this is the right approach.
However, depending on the situation, there are other alternatives, such as hidden variables, iframes, etc. If you could explain the whole situation, depending on the nature of the data, I can provide you with a very accurate answer.
source share