javascript - Trouble making a decision from an ajax request response -


i'm doing ajax request jquery check whether username taken or not in database , changing text inside div (in case div id="wnguser"). able response php script , text appear should (i echo 1 of 2 strings: "username available" or "username unavailable" php script). not able though use response php script, variable data (in case 1 of 2 strings mentioned above) make decision.

for example the if() marked //does not work. can tell me how make if() work or correct way take decision base on response of php script 1 of 2 strings.

thank you

<script type="text/javascript">          $(document).ready(function(){          $('#username').keyup(function(){              var user = $('#username').val();             $.post('checkusername.php', {username: user}, function(data){              $('#wnguser').html(data);              //does not work             if (data === "username available"){                  execute code             }              });          });            });      </script> 

in checkusername.php have give condition instead of current file.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -