call value of a variable from php page by ajax -
i new javascript , i've searched question everywhere no suitable answer. have "code.php" page as
$query = "select * users id=1"; $result= mysqli_query($con,$query); $row=mysqli_fetch_array($result); echo $row[1]; on other side in "index.php" have
<h1>"the value number is: " <span id="mytext"></span></h1> function myfunction() { document.getelementbyid("mytext").innerhtml = $row[1]; } i want load value of $row[1] code.php index.php.
i know have use ajax how?
in index php use ajax data code php. example :
<script> $.ajax({ url: 'code.php', type:'get', success:function(data){ $("#mytext").html(data); } }); </script>
Comments
Post a Comment