Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Ajax query is breaking due to trying to redeclare php class

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

PHP code is here

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 ….

Any one got any ideas as to why this might be



— asked July 7th 2010 by Luke Rotherfield
  • class
  • desktop
  • php
1 Comment
  • I have got the same problem(very similar), need some help.

    — commented July 7th 2010 by Jasjeev Singh Anand

2 Answers

  • Accepted Answer

    I'm not sure why you would be making an Ajax call to a PHP script in your own Desktop application. Couldn't you simply invoke a PHP function directly in your app? Here is the guide on using PHP in your desktop application if you haven't come across it already - check out the various methods of including a PHP script in your page, and then invoking a function.

    If you have a specific reason for needing to do what you are doing, let everyone know, but if you just want to call PHP code from your app, I would just include the PHP script and invoke a function directly.

    Or is this PHP script running on your server?

    — answered July 7th 2010 by Kevin Whinnery
    1 Comment
    • Thanks Kevin thats great, very helpful

      — commented July 8th 2010 by Luke Rotherfield
  • I need it here to make use of editable tables using TableGear

    — answered July 7th 2010 by Jasjeev Singh Anand
    1 Comment
    • While I'm not familiar with TableGear directly, you wouldn't necessarily use it in the same way as you would in a web application. There's no ajax round trip with local PHP code in Titanium. I would look into how to directly call TableGear functions via PHP, and then invoke those functions directly in a local PHP script running in Titanium.

      — commented July 7th 2010 by Kevin Whinnery
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.