Guest User

Untitled

a guest
Apr 22nd, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. valid_user() {
  2.  
  3. $id = $_POST('id');
  4.  
  5. if($id == 'hello'){
  6. return true;
  7. }
  8. else{
  9. return false;
  10. }
  11. }
  12.  
  13. $.ajax({
  14. type: "POST",
  15. url: path + "valid_user",
  16. sucess: function(msg) {
  17. alert("Data returned: " + msg );
  18. }
  19. });
  20.  
  21. $.ajax({
  22. type: "POST",
  23. url: "validateUser.php",
  24. data: "id=49",
  25. success: function(msg){
  26. alert( "true or false: " + msg );
  27. }
  28. });
  29.  
  30. success:function(data, textStatus)
  31.  
  32. <?php echo valid_user(); ?>
  33.  
  34. $id = isset($_POST['id']) ? trim($_POST['id']) : '';
  35. $return = 'false';
  36.  
  37. if($id!=''){
  38. valid_user($id);
  39. }
  40.  
  41. echo $return;
  42.  
  43. valid_user($id) {
  44. if($id == 'hello'){
  45. $return = 'true';
  46. }
  47. }
  48.  
  49. <script>
  50. id = 'hello';
  51. $.ajax({
  52. type: "POST",
  53. url: "validateUser.php?id="+id,
  54. success: function(msg) {
  55. alert("Data returned: " + msg );
  56. }
  57. });
  58. </script>
Add Comment
Please, Sign In to add comment