jquery updating a div in ajax diesnt work properly, when using a variable

Posted by maschek on Stack Overflow See other posts from Stack Overflow or by maschek
Published on 2010-04-03T12:23:57Z Indexed on 2010/04/03 12:33 UTC
Read the original article Hit count: 166

Filed under:
|
|

hi,

i got the following code

      var zieldiv = $(this).attr(\'id\');                                                                                                                                           

                                    $.ajax({
                                         url: \'index.php?params\',
                                         type: \'POST\',
                                         data: { color:thenewcolor, zieldiv:zieldiv },
                                         timeout: 50000,
                                         beforeSend: function() {                                            
                                         $("#" + zieldiv).css({background: "#" + thenewcolor} );

                                           }
                               });

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?

thanx, maschek

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about this