サーバーに接続していくつかの結果を返す php スクリプトを要求する ajax 要求があります。
ここに私のPHPコードがあります:
<?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;
?>
そして、ここに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);
});
}
});
});
これはローカルで正常に動作し、titanium アプリでの最初の ajax 呼び出しでは機能しますが、titanium アプリでの 2 番目の呼び出しでは致命的なエラーが返されます: C:\path-to-app\dist\win32\app- でクラス データベースを再宣言できません。 name\Resources\p\DataBase.class.php の 10 行目 (10 行目はクラス宣言ですclass DataBase{
)
これがなぜなのか、誰もが何らかの考えを持っています
乾杯
ルーク