Advertisement
Guest User

Untitled

a guest
Dec 10th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Untitled Document</title>
  6. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
  7. </head>
  8.  
  9. <body>
  10. <button id="get-Json">Get JSON stuffs</button>
  11. <button id="get-html">Get Html stuffs</button>
  12.  
  13. <p></p>
  14. <script>
  15.  
  16. $(document).ready(function(){
  17. function getHTML() {
  18. $.ajax({
  19. type:'GET',
  20. url:'/ajax/htmlajax.php',
  21. cache:false,
  22. dataType:'html',
  23. success:function( _response ) {
  24. console.log(_response);
  25. $("p").html(_response);
  26. },
  27. error:function( _xhr, _status, _error ) {
  28. console.log( "Error -> " + _xhr + " Status -> " + _status );
  29. }
  30. });
  31. }
  32. $( "button#get-html" ).on( "click", function() {
  33. getHTML();
  34. });
  35.  
  36. function getJSON() {
  37. $.ajax({
  38. type:'GET',
  39. url:'/ajax/jsonajax.php',
  40. cache:false,
  41. dataType:'json',
  42. success:function( _response ) {
  43. console.log(_response);
  44. $("p").html(_response);
  45. },
  46. error:function( _xhr, _status, _error ) {
  47. console.log( "Error -> " + _xhr + " Status -> " + _status );
  48. }
  49. });
  50. }
  51. $( "button#get-Json" ).on("click", function() {
  52. getJSON();
  53. });
  54. });
  55. </script>
  56.  
  57. </body>
  58. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement