• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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:

Messages In This Thread
codeigniter vs ajax [please help a noob] - by El Forum - 01-04-2012, 10:11 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.