Getting Variables on AJAX POST Process

I’m trying to POST something via AJAX but have a little problem which I couldn’t solve.

I have a PHP foreach loop and a delete function. Basically, I want to delete some items in this foreach with AJAX POST request. I can make POST thing but can not get ID value. ID value is too important for me, ’cause system should know which data will delete.

You can find my PHP code below:

 <?php foreach($contactMessages as $c) { ?>
   <td><?php echo $c['name']; ?></td>
   <td><?php echo $c['subject']; ?></td>
   <td><a data-toggle="modal" data-target="#delete" id="delete"></td>
 <?php }?>

And here is my JavaScript code:

<script type="text/javascript">
      url: '<?php echo site_url('admin/messages/delete/'); ?>',
      type: 'POST',
      data: {'submit':true},

As I said, I have to POST unique ID but couldn’t find how to get it via JavaScript. Thanks in advance.

Source: ajax

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.