jquery updating a div in ajax diesnt work properly, when using a variable
- by maschek
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