Aziz-Rahman

ajax

Oct 14th, 2015
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.08 KB | None | 0 0
  1. <!-- ======================= custom.js==================== -->
  2.  
  3. (function($) {
  4.   $('.input-text').on("change", function () {
  5.     //get the selected value
  6.  
  7.     var selectedValue = $(this).val();
  8.         $('.fuck').text( selectedValue );
  9.         // alert($(this).val());
  10.  
  11.     //make the ajax call
  12.     $.ajax({
  13.       url: "testos.php",
  14.       type: "POST",
  15.       data: {url : selectedValue},
  16.       success: function(){
  17.         alert('success');
  18.       },
  19.       error: function(){
  20.         alert('error !');
  21.       }
  22.     });
  23.   });
  24. })(jQuery);
  25.  
  26. <!-- ======================= testos.php ==================== -->
  27.  
  28. <!DOCTYPE html>
  29. <html lang="en">
  30. <head>
  31.   <meta charset="UTF-8">
  32.   <title>Document</title>
  33. </head>
  34. <body>
  35.  
  36.   <?php
  37.   $display_data = isset( $_POST['url'] ) ? $_POST['url'] : '';
  38.   echo $display_data;
  39.   var_dump($display_data);
  40.   ?>
  41.  
  42.   <form action="" method="post">
  43.     <input type="text" class="input-text" name="inputtxt" placeholder="Input Your Text">
  44.   </form>
  45.  
  46. <script src="jquery-1.11.1.js"></script>
  47. <script src="custom.js"></script>
  48. </body>
  49. </html>
Advertisement
Add Comment
Please, Sign In to add comment