I started the jQuery tutorial made by phpAcademy on thenewboston youtube channel. I reached the part where I have to create an email validation form BUT, I am not using PHP, I am using ASP.net for this tutorial.
So, the thing is that even though I did everything as said in the tutorial, I can't send any variable to the .aspx page by using $.post and when I want to retrieve the variable from the .aspx page, it retrieves me the entire source code.
The source code for the Main page:
<input type="text" id="email" /> <span id="emailfeed"></span>
Javascript file with jQuery code:
function validate_email(email) {
$.post('email.aspx', { email: email }, function (data) {
$('#emailfeed').text(data);
});
}
$('#email').focusin(function () {
if ($('#email').val() === '') {
$('#emailfeed').text('Enter your email here');
} else {
validate_email($('#email').val());
}
}).blur(function () {
$('#emailfeed').text('');
}).keyup(function () {
validate_email($('#email').val());
});
The email.aspx.cs code:
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack)
{
string email = Request.Form["email"];
emailLabel.Text = email;// HTTP Post
}
}
What this code does is to send everything I type in the field to the email.aspx and then retrieve what arrived in the email.aspx and showing it in the span tag "emailfeed". So basically, what I write in the email field it should be displayed between the span tags... but this doesn't happen and instead that, I get this:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>
</title></head>
<body>
<form method="post" action="email.aspx" id="form1">
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="6/oBNs2tFeYkrpkFpDL724BXcQwQ8axaBMe/+VEr/27lNqbjE1FyzyK6Zrl2TCcvjgfkv01vyV3PXehcal8bJZdEfpf4v5KkxQTelnzKhlM=" />
</div>
<div>
<span id="emailLabel"></span>
</div>
</form>
</body>
</html>
So basically this is the source code of the email.aspx showing up between instead of what I'm actually typing.
How can I sort this out?