I have a textarea.. I just want to send the textarea value whenever it changes to the database..I have tried something..But it's not working out..Can anyone help here?
Index.php
<textarea id="cap'.$id.'"></textarea>
AJAX
var i = <?php echo $id; ?>
$(document).ready(function() {
$("#cap"+i).keyup(function(){
var cap = $("#cap"+i).text($(this).val());
$.post('send.php', {cap:cap, i:i}, function(data){
});
});
});
send.php
$cap = $_POST['cap'];
if($cap){
if($cap == ""){
$cap = "Caption Not Given Yet";
}
$sql = mysql_query('UPDATE table SET caption="'.$cap.'" WHERE id="'.(int)$_POST['i'].'"')or die(mysql_error());
}
It's not working...