Pages 1
xajax PHP Class Library - The easiest way to develop asynchronous Ajax applications with PHP
You are not logged in. Please login or register.
tried installing it. doesn't work for me. Safari, Mac OSX.
i get the following error.
i used the following setup:
require_once '../xajax/xajax_core/xajax.inc.php';
require_once '../xajax/xajax_core/xajaxPlugin.inc.php';
require_once '../xajax/xajax_core/xajaxPluginManager.inc.php';
require_once '../xajax/xajax_core/xajaxResponse.inc.php';
require_once '../xajax/xajax_plugins/response/comet/comet.inc.php';
require_once '../smarty/Smarty.class.php';
require_once 'connections/local.php';
require_once 'php/utility.php';
require_once 'classes/base.php';
require_once 'classes/dependent.php';
require_once 'classes/user.php';
$xajax = new xajax("xxx.server.php");
$xajax->registerFunction('test');
$xajax->registerFunction('loginForm');
//$xajax->register(XAJAX_FUNCTION, 'testComet', array("comet" => true));
$xajax->setCharEncoding('ISO-8859-1');
$xajax->setFlag('decodeUTF8Input', true);
$xajax->setFlag('debug', true);
$smarty = new Smarty;
?>
Ok so I looked at a previous version to set it up correctly
ini_set("display_errors",1);
error_reporting(E_ALL ^E_NOTICE);
$core = '../xajax/xajax_core';
require_once $core . '/xajax.inc.php';
$xajax = new xajax("airline_support.server.php");
require_once $core . '/xajaxPlugin.inc.php';
require_once $core . '/xajaxPluginManager.inc.php';
require_once '../xajax/xajax_plugins/response/comet/comet.inc.php';
require_once '../smarty/Smarty.class.php';
require_once 'connections/local.php';
require_once 'php/utility.php';
require_once 'classes/base.php';
require_once 'classes/dependent.php';
require_once 'classes/user.php';
$xajax->configure("javascript URI","/xajax/");
$xajax->registerFunction('test');
$xajax->registerFunction('loginForm');
$xajax->register(XAJAX_FUNCTION,"testComet",array("comet" => true));
$xajax->register(XAJAX_FUNCTION,"testNormal");
$xajax->setCharEncoding('ISO-8859-1');
$xajax->setFlag('decodeUTF8Input', true);
//$xajax->setFlag('debug', true);
$smarty = new Smarty;
?>
now the only issue I have is that comet does not work with the debug menu
i get that the URL for debug.js is not found, etc.
I was searching the net for using comet technique with php and found out this plugin. Great work.
But can you please give an example of:
Suppose a function "getdata" retreives something from the database and returns a string "datastring". How can I can I use comet plugin to display that string in the div so that the div only refreshes when there's some change in data?
One thing I want to ask, when running the demo from:
http://xajaxproject.org/developer/q_no/Comet/comet.php
After clicking on start button if I click the Escape key, it does not stop and continues to run until finished.
But when I downloaded the demo from:
http://xajaxproject.org/developer/q_no/Comet/Comet.zip
and executed it locally, after pressing the start button if I press the Escape key, the scrip stops.
Can you please tell me how the script does not stop when executed from http://xajaxproject.org/developer/q_no/Comet/comet.php?
Works fine for me, smughal! (Using Firefox)
Comet doesnt work in IE 6 with xajax RC2 (using compiled version), throwing error context is null. Xajax files in your package are not from RC2 so it works well in IE 6. Got comet.js from online demo, that worked with latest RC2.
Last edited by Goodwill (2009-01-08 3:29:24 PM)
Works fine for me, smughal! (Using Firefox)
Ok. I executed it (both links) in firefox and after pressing the Start button if escape is pressed, the script stops. What if I don't want it to be stopped? The idea is that the script will continuously check a table from database if any new record is added in it, if yes then some action will be performed. I want to do it using comet streaming. So if the script is running and someone presses escape then the script will stop. How to make it Not stop?
Thank you.
Oh, I see, interesting question. I think you have to deal with preventing the escape key yourself. Below is a test script that uses jquery to discard escapes. I've tried it on Firefox and IE6 (on Ubuntu/Wine) and it works ok but I'm not sure of side-effects.
To Goodwill: Thanks for pointing out that one needs to use http://xajaxproject.org/developer/q_no/ t/comet.js or http://xajaxproject.org/developer/q_no/ pressed.js for comet to work under IE, rather than the version in the download zip - it flummoxed me until I read your post.
<?php
define('DM_AJAX_URI_PATH', '/dm/_/include/'); // NOTE: Change for your system.
define('DM_AJAX_FULLDIR', '/var/dm/xajax/xajax_core/'); // NOTE: Change for your system.
require DM_AJAX_FULLDIR . 'xajax.inc.php';
require_once DM_AJAX_FULLDIR . 'xajaxPluginManager.inc.php';
require_once DM_AJAX_FULLDIR . 'xajaxResponse.inc.php';
require_once DM_AJAX_FULLDIR . '../xajax_plugins/response/comet/comet.inc.php';
error_log("begin {$_SERVER['PHP_SELF']}");
function testComet () {
$objResponse = new xajaxCometResponse(0.3);
for ($i = 1; $i <= 10; ++$i) {
$objResponse->assign("progress","style.width",($i*5)."px");
$objResponse->assign("streaming","innerHTML",($i*5).'%');
$objResponse->flush();
}
$objResponse->assign("progress","style.width",($i*5)."px");
$objResponse->assign("streaming","innerHTML",($i*5).'%');
$objResponse->alert("finished process at ".($i*5)."%.");
return $objResponse;
}
$xajax = new xajax;
$xajax->configure('javascript URI', DM_AJAX_URI_PATH);
$xajax->register(XAJAX_FUNCTION, "testComet", array("comet" => true));
$xajax->processRequest();
error_log("end {$_SERVER['PHP_SELF']}");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head>
<title>Test comet</title>
<?php
$xajax->printJavascript();
?>
<script type="text/javascript" src="/dm/_/include/jquery/jquery-1.2.6.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('body').keydown(function (e) { if (e.which == 27) return false; });
});
</script>
</head>
<body>
<input type="button" onclick="xajax_testComet();" value="start comet" />
<div id="progress" style="width:1px;background:red;border:1x solid darkred">
<div id="streaming"></div>
</div>
<div id="debug"></div>
</body>
</html>
hello i try to using comet but form me doesn't work
i use firefox 3.0 and xajax 5.0 and Comet Streaming plugin 0.2.2
with ie 7 comet work
Just had a problem with Comet and Internet Explorer 8. I was getting this error:
Message: 'context' is null or not an object
Line: 130
Char: 215
Code: 0
URI: http://mydomain.com/xajax/xajax_js/xajax_core.js
I fixed this error by adding an "if" statement in, like so:
if(obj.context){obj.context=oRequest.context;}
Works like a charm now.
Never had a problem with xajax or comet plugin. but I am now.
Seems that I am getting an invalid url error. I don't know why. The script works just fine on another site. for the site with the error it works fine in firefox and chrome. But not in IE8.
I am getting to this point in the comet.js file
xjxEc.connect_htmlfile=function(url,callback,oRequest){try{xjxEc.transferDoc=new ActiveXObject("htmlfile");xjxEc.transferDoc.open();xjxEc.transferDoc.write("<html>");xjxEc.transferDoc.write("<script>document.domain='http://192.168.1.21/';</script>");xjxEc.transferDoc.write("</html>");xjxEc.transferDoc.close();xjxEc.ifrDiv=xjxEc.transferDoc.createElement("div");xjxEc.transferDoc.body.appendChild(xjxEc.ifrDiv);xjxEc.ifrDiv.innerHTML="<iframe src='"+url+"'></iframe>";xjxEc.transferDoc.callback=function(response){callback(response,oRequest);};}
catch(ex){}
}
That appears to be where it chokes. It doesn't like the document.domain. Any ideas?
I am having a problem with IE working with Comet. I don't know if this is the problem but I don't know why this is like this.
On line 276 of the comet_uncompressed.js the code shows non existant address. This is a private address.
Is this an issue?
Posts [ 13 ]
Currently used extensions: pun_repository. Copyright © 2008 PunBB
[ Generated in 2.680 seconds, 9 queries executed ]