Wednesday, 2 October 2013

jQuery Post non working

jQuery Post non working

I'm trying to send via javascript some variables to a php file which will
store them in a db. However nothing happens and I don't find my mistake. I
am sure that the variables are initizialised in javascript and they are
not in php (cause the php code write an empty log). Can you help me?
Thanks a lot
Javascript code:
<script src="http://localhost:8080/libs/jquery-1.10.2.min.js"></script>
<script>
function returned(data) {
alert(data);
}
function postSecret()
{
....
alert(v_text + "\n" + v_age + "\n" + v_is_male);
jQuery.post( "http://localhost:8080/libs/post.php", { text:
v_text, age: v_age, is_male: v_is_male }, returned(data),
"json");
}
</script>
Post.php:
<?php
printf("dkls");
$file = 'log.txt';
$content .= "session: ".$_POST['text']." || ".$_POST['is_male']."
|| ".$_POST['age']."\n";
file_put_contents($file, $content, FILE_APPEND | LOCK_EX);
... database...
?>

No comments:

Post a Comment