skip to Main Content

It is showing undefined function in PHP page.And i made every possible way it is not working for me.Please guys help me with this.

<!DOCTYPE html>
<html>
    <head>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
    </head>
    <body>
       <div id="myDiv">Welcome to stackoverflow</div>
    </body>
    <script>
       $(document).ready(function(){
            var mb = $('#myDiv').text();
            $.ajax({
                action : "six-cuf.php",
                type: 'POST',
                data: { 'mb': mb},
                success:function(data)
                {
                    alert(mb);   
                }
            });
        });
    
    </script>
</html>

PHP CODE

<?php  
  $fname = $_POST['mb'];
?>

2

Answers


  1. Hello

    $(document).ready(function(){
      var mb = $('#myDiv').text();
      $.ajax({
        action : "six-cuf.php",
        type: 'POST',
        data: { mb: mb},
        success:function(data)
        {
          alert(mb);   
        }
      });
    });
    
    Login or Signup to reply.
  2. You can also try this JQuery Post Method

    Javascript Code

    $.post("six-cuf.php", {'mb': mb}, function (data) {
          console.log(data);
     });
    

    PHP code

    <?php
    $fname = $_POST['mb'];
    echo $fname;
    ?>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search