simple $.post() problem
simple $.post() problem
i am totally confused about the function i made:
my js inside <head> tag, after the jquery.js:
- <script type="text/javascript">
- $(document).ready(function(){
- function addasfriend(){
- var n = $(this).attr('id');
- $.post('test.php',{f:n},function(r){
- alert("Newly added: " +r);
- });
- }
- });
- </script>
my html <body> (ID tag = name_is_here, supposively the name of a person)
- <a href="#" id="name_is_here" onclick="addasfriend();">Add as friend</a>
the test.php page
- <?php
- if(isset($_POST)){
- echo $_POST['f'];
- }
- ?>
why isn't working?
- any suggestion is highly appreciated. thanks!