As I suspected, things are not as described.
First off, you haven't defined any variables at all. Since you
haven't used var
to declare them, your variables are, in fact, global.
I can't do anything with your fiddle, though. Can you create an
example that doesn't have to access Facebook? I suspect you have a
cross-domain Ajax issue to deal with (I get a "frame was
blocked" error). Can we take that out of the equation and solve
your scoping problem?
Edit: I suppose not, since the purpose of the code is to do a POST
to Facebook. Are you sure you are using their API correctly? Did you
seek advice from Facebook developer documentation and forums?
I notice that you try to interate through sg. But you never set a
value in sg. Of
course, if you iterate through nothing, the code will do nothing.
I'd start with a known working example of the Facebook POST you are
trying to do. We can't help much with that here.