Hoi allen!
Al lange tijd loop ik te denken om nu eindelijk eens Xajax te implementeren op mijn website. Dus ik ben aan de gang gegaan met een nieuw frameworkje, maar het lijkt niet te werken.
Als ik xajax zo aanroep:
Toont het heel mooi de "YAY" als ik op de knop druk, maar als ik het in mijn framework zet, dan werkt er helemaal niets. De hele pagina laad tot op het punt waar ik:
doe.
In de classen ziet het er zo uit:
Als ik de $this->$xajax = new xajax(); weghaal, werkt het perfect.
Al lange tijd loop ik te denken om nu eindelijk eens Xajax te implementeren op mijn website. Dus ik ben aan de gang gegaan met een nieuw frameworkje, maar het lijkt niet te werken.
Als ik xajax zo aanroep:
PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
| <?php require_once ('../../private/cursor/site/classes/xajax_core/xajax.inc.php'); $xajax = new xajax("test.php"); $xajax->registerFunction("alert"); $xajax->processRequest(); function alert() { $xajax_response = new xajaxResponse(); $xajax_response->alert("YAY"); return $xajax_response; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="nl"> <head> <title>Title</title> <script type="text/javascript" src="scripts/xajax_core.js"></script> <script> <?php $xajax->printJavascript(); ?> </script> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> </head> <body> Xajax version: <?php echo $xajax->getVersion() ?><br/> <button onclick="xajax_alert();">haha</button> </body> </html> |
Toont het heel mooi de "YAY" als ik op de knop druk, maar als ik het in mijn framework zet, dan werkt er helemaal niets. De hele pagina laad tot op het punt waar ik:
code:
1
| $this->xajax = new xajax(); |
doe.
In de classen ziet het er zo uit:
PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
| <?php session_start (); require_once ('../../private/sitename/site/classes/adodb_lite/adodb-exceptions.inc.php'); require_once ('../../private/sitename/site/classes/adodb_lite/adodb.inc.php'); require_once ('../../private/sitename/site/classes/xajax_core/xajax.inc.php'); require_once ('./Config.php'); function __autoload ($class_name) { $class_path = '../../private/sitename/site/classes/'; $class_name = ucfirst (strtolower ($class_name)); if (file_exists ($class_path.$class_name.'.php')) require_once ($class_path.$class_name.'.php'); else die ('Could not locate class '.$class_name); } $controller = new Controller (); ?> |
PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
| <?php class Controller { private $config; private $logger; private $site; private $error; private $connection; public $database; public $xajax; function __construct () { $this->config = new Config (); $this->config = $this->config->get_config(); try { $this->logger = new Logger ($this, $this->config); $this->logger->log_message (4, 'New connection accepted'); $this->logger->log_message (4, 'Logger succesfully created'); } catch (Exception $exception) { $this->error = new Error ($this, $this->config, 'LOGGER_LOAD_FAIL'); } try { $this->logger->log_message (4, 'Start loading database object'); $this->database = ADONewConnection('mysql'); $this->connection = $this->database->Connect($this->config['db_host'], $this->config['db_user'], $this->config['db_pass'], $this->config['db_name']); $this->logger->log_message (4, 'Database connection created to: '.$this->config['db_host']); } catch (Exception $exception) { $this->logger->log_exception ($exception); $this->logger->log_message (2, 'Loading of database connection failed. See above for error messages.'); $this->error = new Error ($this, $this->config, 'DB_LOAD_FAIL'); } $this->logger->log_message (4, 'Start loading xajax instance'); $this->$xajax = new xajax(); try { $this->logger->log_message (4, 'Start loading site'); $this->site = new Site($this, $this->config); $this->site->load_site(); $this->database->Disconnect ($this->connection); } catch (Exception $exception) { $this->logger->log_exception ($exception); $this->logger->log_message (2, 'Loading of the site failed. See above for error messages.'); $this->error = new Error ($this, $this->config, 'SITE_LOAD_FAIL'); } } public function db_isConnected() { if ($this->connection != null) return true; else return false; } } ?> |
Als ik de $this->$xajax = new xajax(); weghaal, werkt het perfect.
[ Voor 0% gewijzigd door een moderator op 11-11-2008 00:48 . Reden: Code highlighting FTW \0/ ]
A byte walks into a bar and orders a pint. Bartender asks him "What's wrong?" Byte says "Parity error." Bartender nods and says "Yeah, I thought you looked a bit off."