0

this is my code

<input type="text" id="name" class="name"> 
<button id= "det_submit" onclick="submit_det()"> Submit </button>   
<script>
function submit_det() {    
    if(document.getElementById("name").value != "") {   
       $.post(
             'subscribe.php',{email : document.getElementById("name").value},
              function(data){
                  alert(data);
              });
    } else {
         alert("empty");
     }
   } 
</script>

the variable email is not sent to subscribe.php page...any help appreciated...Thank you

Vikas Arora
  • 1,655
  • 2
  • 17
  • 36

1 Answers1

0

Try this way, your code is good but you didn't include JQUERY API, i have added CDN link, you can add the local version after downloading it.

<input type="text" id="name" class="name">
<button id= "det_submit" onclick="submit_det()"> Submit </button>
<script src="https://code.jquery.com/jquery-1.11.2.js"></script>
<script>
    function submit_det() {
        if(document.getElementById("name").value != "") {
            $.post(
                'subscribe.php',{email : document.getElementById("name").value},
                function(data){
                    alert(data);
                });
        } else {
            alert("empty");
        }
    }
</script>
Always Sunny
  • 32,751
  • 7
  • 52
  • 86