Advertisement
Guest User

Untitled

a guest
Jan 17th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. <script>
  2. $(document).ready(function(){
  3. $('#getUser').on('click',function(){
  4. var user_id = $('#user_id').val();
  5. $.ajax({
  6. type:'POST',
  7. url:'test.php',
  8. dataType: "json",
  9. data:{user_id:user_id},
  10. success:function(data){
  11. if(data.status == 'ok'){
  12. $('#userName').text(data.result);
  13.  
  14. $('.user-content').slideDown();
  15. }else{
  16.  
  17. alert("User not found...");
  18. }
  19. }
  20. });
  21. });
  22. });
  23.  
  24. <input type="text" id="user_id" />
  25. <input type="button" id="getUser" value="Get Details"/>
  26. <div class="user-content" style="display: none;">
  27. <h4>User Details</h4>
  28. <p>Name: <span id="userName"></span></p>
  29. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement