I use this for dragging a small div into a bigger div. the variable at the beginnning would give out the string "test1". So in the ajax thing the css of a div which matches the var zieldiv should be updatet. Problem is, if i would place a string instead a var into the $(...) like $("#test1") it acts like its supposed to, the #test1 gets updated. but if i use the var $("#" + zieldiv) the parent div, which is surrounding the #test1-div gets updated.
but i know for sure the var zieldiv contains the string "test1", because when passing it to php it contains "test1". so i think this is a little strange. do you have any ideas?

I'm guessing this is a simplified example, make sure you have the variable defined before your ajax call so it's passed into the closure, using something like this inside the callback won't work, because it doesn't know what you're talking about, this is in a different context when it returns.

its not working like this. the thing is, the variable seems to have the right string in it, but its not recognized right, when placing it in the $(...). when is use a static value its working.
–
maschekApr 3 '10 at 16:22

@maschek - If you alert(zieldiv) right after assigning it, what do you see?
–
Nick Craver♦Apr 3 '10 at 16:25

interesting! i placed an alert(zieldiv) and it actually gave two (!) alerts, first the one with the parent div, then the right one, the div i actually want to apply to. so its two divs inside the var, one to much. so, would there any way to split this var zieldiv in two parts?
–
maschekApr 3 '10 at 16:49

@mascheck - That means your function is being called twice, can you update the question with the code around that's calling this? Most likely the selector that you're using to bind this event is including the parent as well.
–
Nick Craver♦Apr 3 '10 at 16:54

yes, it seems like that. but do you have any idea how to prevent that the event includes both? thanks, maschek
–
maschekApr 3 '10 at 17:38