javascript - Post data to current php page with ajax -
i want post data current page ajax.but couldnt that.
i have doctor panel , wanna patient's data 'hastalar' table in db using patient's national id:'tc'.session using doctor guess cant use $_session patient @ same time.and wanna use 1 php page.so cant see patient's datas in current page.pls me guys.
dokyon.php
textbox
<a href="#" id="ara" class="ara" ><br/>search patient</a> <input type ="text" id="tc" name="tc" />
jquery
<script type="text/javascript" > $(function() { $(".ara").click(function(){ var tc = $('#tc').val(); $.ajax({ url:'dokyon.php'//current page type: 'post', data:{tc:tc}, success: function(){ alert(data); } }); }); }); </script>
php codes
<?php $tc=$_post['tc']; echo $tc; $query = mysqli_query($connection,"select * hastalar tc_no=$tc"); while($hasta = mysqli_fetch_array($query)){ echo $hasta['name'];} ?>
for ajax code, need add datatype parameter , add parameter of success: function(data)
, this:
$.ajax({ url:'dokyon.php'//current page type: 'post', data:{tc:tc}, datatype:"html", success: function(data){ alert(data); } });
for additional: debuging sending data inspect element of browser. success :)
Comments
Post a Comment