Reputation: 17
function updateCount(text){
text = encodeURIComponent(text);
$.post("../process/countpaste.php", {text: text}).done(function( data ) {
$( "#stats" ).empty().append($( data ));
});
}
On countpaste.php,
<?php
$text = urldecode($_POST['text']);
?>
<?=strlen($text)?> characters, <?=str_word_count($text)?> words, <?=substr_count($text, "\n")?> lines
For some reason, the string from the PHP page is not being placed in the #stats div. Stats exists, and this method is getting called properly.
Upvotes: 0
Views: 55
Reputation: 11106
function updateCount(text){
text = encodeURIComponent(text);
$.post("../process/countpaste.php", {text: text}).done(function( data ) {
$( "#stats" ).empty().append( data );
});
}
not $(data)
but just (data)
Upvotes: 3