I have html structure like this:
<div class='inside'>
<div>429185</div>
<div>492128</div>
</div>
Sometimes there is only one div inside. I need to get both numbers, and to send them via ajax to php script. Here is how ajax look like:
var value_of_divs = jQuery(".inside div").text();
jQuery.ajax({
type: 'POST',
data: {
action: 'someaction',
code: value_of_divs
},
url: '/somescript.php',
success: function(msg) {
jQuery('#somediv').html(msg);
}
});
But as you can see, this works only when one div is in “inside” div. When two divs are there (like in example), i get nothing from php script. How to pickup content of both divs (as array?) and to send them to ajax?
1 Answer