Unless there are other differences between the left and right frame, I'd look into the anchoring options for text frames. I believe there are options such as "away from spine", and other, that can automatically place an anchored textframe depending on left or right.
Consider this a mere hint, since I don't fully grasp the situation / problem. (Eg. is scripting already involved, are you importing xml or is it a "plain template" that you are setting up?)
Scripting is involved since it is an automated process where it imports XML, does a couple of modifications, and exports a PDF for each XML file.
On each page, I have a main text frame (the main content area) and a left side placeholder and a right side placeholder. Left pages need to display the left side placeholder etc.
How do I use anchored objects to set left and right? what options do I exactly set in the anchored object options?
You'll have to figure out whether this can help you at all, by setting up a document by hand first. Paste a textframe at the cursor position in you main text, select the new object, and then right-click and select anchored object.
There you can set up the anchored object to appear a certain distance from the spine.
I'm not sure how to handle this within an xml-import. Try tagging the anchored frame, and see what happens.
If it seems to work out, you would probably use TextFrame.anchoredObjectSettings to set things up from the script.
I get this result, checking the existing properties of an anchored textframe in a document:
You could also look up "AnchoredObjectSetting" in the Object Model Viewer, in the Extendscript Toolkit, to see all it's settings.
Best of luck to you!