I’m trying to get all loop results into one then using ajax to send all of them only once
Here’s the code for more explanation :
<div class='item'>Name1</div>
<div class='item'>Name2</div>
jquery
$(".item").each(function(){
var value = $(this).text();
});
^ this returns both Name1 and Name2 but not at once, i need to merge them together so i can send them both to an ajax request
this is how i want it ( invalid code )
$(".item").each(function(){
var value1 = $(this[0]).text(); // even tho i dont wanna use numbers, i wanna all of them
var value2 = $(this[1]).text();
var final = value1 + value2; // Name1Name2
});
$.get('go.php', {items : final}, function(...
this is an invalid code ^ just to give you an example of how it should end with
first problem is merging, i don’t know how it should be,
and second is i want to call var final from outside the loop so it wont repeat the request
Fiddle: http://jsfiddle.net/iambriansreed/Wf3SF/
Try:
Or:
Or as you mentioned in your comments:
Or finally like this: