views:

7

answers:

0

Hi all,

I have an ajax request that requests a php script that connects to my server and returns some results

Here is my PHP code:

<?php
require_once 'p/DataBase.class.php';
if (!isset($db)) //i added this if statment incase this caused the error
  $db = new DataBase();
$db->query('select * from table where status = 0 order by created_at desc');
$xml = ''; //$xml is just a variable, im not passing the data as xml, i was originally and didnt change the var name
while ($data = $db->fetchObject()) {
  $xml .= $data->title . "<br />";
  $xml .= $data->created_at . "<br />";
}
echo $xml;
?>

And here is the JQuery:

$(document).ready(function () {

  function runAjax (data_obj,callback){

    $.ajax({
      url:"ajax.php",
      dataType: "html",
      data: data_obj,
      success: function(html) {              
        if ( typeof(callback) == "function") {
          callback(html);
        }
      }
    });
  }
  jQuery.timerDelayCall({
    interval: 10000,
    repeat: true,
    callback: function(timer) {
      runAjax({
        content: $('#date').html()
      }, function(result){
        $('#updates').html(result);
      });
    }
  });
});

This works fine locally and works the for the first ajax call in the titanium app, but the second call in the titanium app returns a fatal error: Cannot redeclare class DataBase in C:\path-to-app\dist\win32\app-name\Resources\p\DataBase.class.php on line 10 (line 10 being the class decleration class DataBase{)

Any one got any ideas as to why this might be

Cheers

Luke