ParthaPreetham Krishna ParthaPreetham Krishna - 5 months ago 21
Javascript Question

Uncaught Reference Error: $ is not defined get method

<script type="text/javascript">
function s()
{
alert("hello");
$email = document.getElementById("inp_subscribe").value;
alert($email);
$.get("subscribe.php",{inp_subscribe: $email },"");
alert($email);
}
</script>


Please help me to learn how to get this
$.get ()
fuction to work.

Answer

Try this code...

function s() {
    alert("hello");
    var $email = document.getElementById("inp_subscribe").value;
    alert($email);
    $.get("subscribe.php",{inp_subscribe: $email },"");
    alert($email);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<label for="inp_subscribe">Email:</label>
<input name="inp_subscribe" id="inp_subscribe" type="email"/>
<button onclick="s();">Submit</button>

Comments