jquery การส่งค่าแบบ ajax

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js">
</script>
<script>
$(document).ready(function()
{
     <!-- Event -- >
     $("#ok1").click(function()
     {
          <!-- Action -->
          $.ajax
          ({
               method: "POST",
               url: "how2devajax.php",
               data: {
                       "var_1" : $('#p1').val(),
                       "var_2" : $('.text').val()
                     },
               success: function(result)
               {
                     $('#return_tag_id1').val(result.return_var1);
                     $('#return_tag_id2').val(result.return_var2);
               }
          });
     });
});
</script>
</head>
<body>
<p class=text id=p1> how2dev.net </p>
<p class=text id=p2> javascript </p>
<p class=text3 id=p3> jQuery </p>
<button id=ok1>OK1</button>
<p return_tag_id1=p1></p>
<p return_tag_id2=p2></p>
</body>
</html>

 

Leave a Comment

Your email address will not be published. Required fields are marked *