javascript - sending $.post to .aspx using jQuery -


i started jquery tutorial made phpacademy on thenewboston youtube channel. reached part have create email validation form but, not using php, using asp.net tutorial.

so, thing though did said in tutorial, can't send variable .aspx page using $.post , when want retrieve variable .aspx page, retrieves me entire source code.

the source code main page:

<input type="text" id="email" /> <span id="emailfeed"></span> 

javascript file 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 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 code send type in field email.aspx , retrieve arrived in email.aspx , showing in span tag "emailfeed". basically, write in email field should displayed between span tags... doesn't happen , instead that, 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 source code of email.aspx showing between instead of i'm typing.

how can sort out?

i've seen sort of strange behaviour before, showing of page source. seem recall due ajax call returning contenttype confuses asp.net framework. try setting datatype of $.post html.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -