0

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...

4

1 に答える 1

0

変えるだけ

var cap =  $("#cap"+i).text($(this).val()); 

var cap =  $(this).val();
于 2013-08-05T14:22:32.440 に答える