I am trying to delete a value in a comma seperated string in a table. The script that does this (delete_url.php) works fine on it's own if I set the post values manually, but I'm having a problem passing those values to the script with ajax. In the page that I want to pass the values from I have:
<script type="text/javascript">
$(document).ready(function() {
$('.delete').click(function() {
$.ajax({
type: 'POST',
url: '../scripts/delete_link.php',
data: 'link=' + $(this).attr('data_link') + '&topic_pk=' + $(this).attr('data_topic'),
success: function() {
}
});
});
});
</script>
And:
<a class='delete_link' href='#' data_link='<?php echo urlencode($link); ?>' data_topic='<?php echo $topic_pk; ?>' onclick="return confirm('Are you certain you want to DELETE this link?')";><img src="../images/delete.png" width="16" height="16" alt="delete" title="delete this link" border='0' /></a>
I probably should be using json, but not sure of the correct way to do this. Thanks for any help.