Fetch data using ajax

Author Topic: Fetch data using ajax  (Read 168 times)

Offline helenedwardsTopic starter

  • Trade Count: (0)
  • Newbie
  • *
  • Thank You 0
  • Posts: 2
  • Karma: 0
    • bad moms movie
Fetch data using ajax
« on: 10-08-2016, 03:04:16 »
hi, I have two tables in my database first one id and the other one text.

this is index.php file I can fetch the data from db like this way


<?php include "config.php"?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">

<title>Title</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-3.1.1.min.js"></script>
<script type="text/javascript" src="ajax.js"></script>
</head>
<body>

<ul>

<?php
$result = $db->query("select * from veri ORDER BY id DESC ");
while ($row = $result->fetch_object()) {
echo '<li id="'.$row->id.'">'.$row->text.'</li>';
}


?>
</ul>

</body>
</html>
what I want to do is that once I insert a new item into a database this item is supposed to show up on top of the list without refrehing the page .This is my code but It doesnt work What am i doing wrong

ajax.js file

Code:
Only registered users can see contents. Please click here to Register or Login.
this ajax.php file

Code:
Only registered users can see contents. Please click here to Register or Login.
newbielink:http://watch68.net/movie-genres/romance [nonactive]


 

Related Topics

  Subject / Started by Replies Last post
18 Replies
8186 Views
Last post 04-19-2016, 01:26:11
by TomClarke
1 Replies
1484 Views
Last post 03-25-2013, 02:22:46
by convergent
1 Replies
1408 Views
Last post 02-17-2016, 01:39:45
by ShreyaKoushik
0 Replies
776 Views
Last post 07-28-2015, 06:48:20
by parththakkar
0 Replies
580 Views
Last post 06-30-2016, 05:59:27
by chinmay.sahoo