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,666
  • 2
  • 17
  • 38

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>
A l w a y s S u n n y
  • 36,497
  • 8
  • 60
  • 103