Welcome Guest, Not a member yet? Register   Sign In
codeigniter vs ajax [please help a noob]

hi all.
i am studying how does ajax works to improve my skills.

i begin with a simple php example (no codeigniter) and i modified that to use with my database. all ok. now i was trying to understand how to use ajax with codeigniter, but after hours of researches i am still at zero.

can anyone explain to me how convert this simple example into a codeigniter mvc example?
i think this is best method for me to learn use codeigniter and ajax and this can help other noob users like me to begin to use ajax with ci!

thanks a lot!

example [php]:

$con = mysql_connect('localhost', 'root', 'root');
if (!$con)
  die('Could not connect: ' . mysql_error());

mysql_select_db("db", $con);

$sql="SELECT * FROM commenti";

$result = mysql_query($sql);

echo "<table border='1'>

while($row = mysql_fetch_array($result))
  echo "<tr>";
  echo "<td>" . $row['codC'] . "</td>";
  echo "<td>" . $row['data'] . "</td>";
  echo "<td>" . $row['commento'] . "</td>";
  echo "<td>" . $row['taskid'] . "</td>";
  echo "</tr>";
echo "</table>";


example [html]
function showComments()

if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

  if (xmlhttp.readyState==4 && xmlhttp.status==200)

&lt;input type="button" value="cliccami" name="bottone" /&gt;
<br />
<div id="txtHint"><b>Person info will be listed here.</b></div>


The original example is this:

Theme © iAndrew 2016 - Forum software by © MyBB