Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3491816
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:40:58+00:00 2026-05-18T11:40:58+00:00

I have an ajax request that requests a php script that connects to my

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T11:40:59+00:00Added an answer on May 18, 2026 at 11:40 am

    So. It seems to be a Titanium bug.
    I have solved it.
    When you declare any class/function, etc, you have to:
    1 – move your functions and classes into some files
    2 – define any constant after require_once your file(s)
    3 – require_once your files only if not defined your constant

    For example:
    i have an AJAX backend called test.php that uses a function from my library lib.php.
    Then i have to write the following:
    In my lib.php:

    define('LIBRARY_INCLUDED',1);
    function directoryToXml($directory) {/*bla bla bla*/}
    

    In my test.php:

    if(!defined('LIBRARY_INCLUDED')) {
        require_once(dirname(__FILE__).'/lib.php');
    }
    

    It happens because Titanium uses PHP file not just like web server does it. The file with its classes and functions exists during the runtime and calling it twice causes to repeated declaration…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible that using jQuery, I cancel/abort an Ajax request that I have
I have written a web app in PHP which makes use of Ajax requests
I have an application in which most requests are submitted via AJAX, though some
I have some AJAX work that brings across an additional form element that I
Several of my ajax applications in the past have used GET request but now
I am using asp.net MVC to develop an application that will have ajax interactions.
With ASP.NET MVC, it is common to have AJAX code(e.g. jQuery) to invoke web
I have an Ajax.Net enabled ASP.Net 2.0 web site. Hosting for both the site
I have $.ajax({ url: identity, success: function(data) { ProcessIdentityServer(data) } }); When 'data' is
I have an ajax toolkit TabContainer control on my page with a couple tabs.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.