foreach($data['data'] as $data){
$count = $data['number'];
}
// $data['number']; will return some number like:
159809
359107
249178
... //10+ numbers
Then, how to put each php foreach value into each jquery ajax? (put every number via a jquery ajax, there will be 10+ ajax calls, and return all the data in one div). Thanks.
<script type="text/javascript">
jQuery(document).ready(function(){
$.ajax({
url: "process.php",
dataType: "html",
type: 'POST',
data: "items=<?php echo $count; ?>", //each $count value in each ajax
success: function(data){
$("#result").html(data);
}
});
});
</script>
<div id="result"></div>
If you really want a unique ajax call for each $count value, with the data returning in the #result div:
However, I would highly recommend passing the values as an array and having only one ajax call:
On the server side in process.php, you can
explode('-',$_POST['items'])and then foreach through them.This is just one other way to accomplish it… It could be json_encoded or many other ways.