jquery each function does everything ^2
hi im trying to make a script, which will call .php by $.post as many times as divs i have in my document.
script looks like this
-
$("#kupit").click(function() {
var hraci = $("div.novakupa").children(".meno");
$(hraci).each(function (i) {
var menohr = $(this).text();
$.post("kupit.php", { meno:(menohr) }, function (echo) {
if (echo != "malop"){
$("#ucet").append(echo);
$("div.novakupa").removeClass().addClass('nakupene');
$("div.napredaj:contains(" +menohr+ ")").remove();
}
});
});
$("#skuska").text('0 <? echo $_SESSION['mena']; ?>');
});
the problem is, that if I have two of these divs, the php script will run 4 times...i there are 3 of them, script runs 9 times. it is very important to run it as many times as number of divs.
$("#ucet").append(echo); is for testing how many times php script will run...its always wrong
help, im stuck
thanks for answer...