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
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>