I have a list that is being created dynamically. The part of the code that creates the list is:
<ul>
<?
foreach ($folders as $folder)
{
$folder = str_replace("{imap.gmail.com:993/imap/ssl}", "", $folder);
$folder2 = str_replace("[Gmail]/", "", $folder);
?>
<li>
<a><div id="box"><? echo $folder2; ?> </div></a>
</li>
<?}
</ul>
<div id="maillist"></div>
o / p from $ folder
GMAIL/All Mail
GMAIL/Drafts
GMAIL/Important
o / p $ folder2
All Mail
Drafts
Important
what I want is that when the user clicks on "All mail", the corresponding value (in this case: GMAIL / All Mail) should go to another script via ajax. The same process should follow other values in the list as well
ajax code
<script>
$(document).ready(function(){
$('#box').change(function(){
var boxid = $('#box').val();
console.log($('#box'))
if(boxid != 0)
{
$.ajax({
type:'post',
url:'a_fetchmaillist.php',
data:{id:boxid},
cache:false,
success: function(returndata){
$('#maillist').html(returndata);
console.log(returndata)
}
});
}
})
})
</script>
Can anyone say if I can do what I want, and if so, how it will be done
source
share