|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
andig Smarty Regular
Joined: 22 Apr 2004 Posts: 48
|
Posted: Wed Dec 12, 2007 3:44 pm Post subject: xajax and smarty problem- invalid content type? |
|
|
I've posted the following problem in the xajax forums [link]http://community.xajaxproject.org/viewtopic.php?pid=22474[/link]:
I'm having severe troubles using xajax w/ smarty. My requirement it to compile and populate a template as aprt of an asynchronous request. This is the (simple) code:
Code: |
function listItems($id, $columns)
{
global $smarty;
$objResponse = new xajaxResponse();
$smarty->fetch('list.tpl', null, null, false);
return $objResponse;
}
|
The problem is, that as soon as I add the smarty->fetch statement, the call fails (not response processor). I've found that actual XML seems to be returned, but the content type is suddenly text/html and I've been unable to find out why.
Any idea how/where this might happen? Does anybody successfully use Smarty w/ xajax?
Thanks,
Andi |
|
Back to top |
|
Celeb Administrator
Joined: 17 Apr 2007 Posts: 1025 Location: Vienna
|
Posted: Wed Dec 12, 2007 4:36 pm Post subject: |
|
|
I guess that something in your template raises an error (which results in printing the error instead of fetch returning HTML code).
Btw if you should capture the result of fetch() in a variable and do something with it. As your script is now you create nothing (but maybe errors and CPU overhead). _________________ Darn computers always do what I tell them to instead of what I want them to do. |
|
Back to top |
|
andig Smarty Regular
Joined: 22 Apr 2004 Posts: 48
|
Posted: Wed Dec 12, 2007 4:41 pm Post subject: |
|
|
Understood. The script is just there for illustration. The thing is that as soon as fetch is called, the content type of the output changes while the message still looks perfectly sensible- this is what xajax log says:
Wed Dec 12 2007 11:23:37 GMT+0100
ERROR: No response processor is available to process the response from the server.
Content-Type: text/html.
Check for error messages from the server.
Wed Dec 12 2007 11:23:37 GMT+0100
RECEIVED [status: 200, size: 205 bytes, time: 217ms]:
<?xml version="1.0" encoding="utf-8" ?>
<xjx>
<cmd n="as" t="docpart_list_target1" p="style.display">none</cmd>
<cmd n="as" t="docpart_list_target2" p="innerHTML">Request executed successfully</cmd>
</xjx>
The request itself seems to be fine. |
|
Back to top |
|
master_kaos Smarty Regular
Joined: 02 Aug 2007 Posts: 54
|
Posted: Wed Dec 12, 2007 5:09 pm Post subject: |
|
|
Someone said they had the same problem it was an apache rewrite problem that caused it. |
|
Back to top |
|
andig Smarty Regular
Joined: 22 Apr 2004 Posts: 48
|
Posted: Thu Dec 13, 2007 7:26 pm Post subject: |
|
|
Module not enabled. Cuoldn't figure it out and decided to simply force xml header:
Code: |
function listItems($id, $columns)
{
global $smarty, $result;
// fix for content type change in async request
header('Content-type: text/xml');
// update session
$_SESSION['vdb']['listcolumns'] = $columns;
// load languages and config into Smarty
tpl_language();
tpl_list($result);
$objResponse = new xajaxResponse();
$objResponse->assign($id.'1', 'style.display', 'none');
$content = $smarty->fetch('list.tpl', null, null, false);
$objResponse->assign($id.'2', 'innerHTML', $content);
// add some delay for debugging
if ($config['debug'] && $_SERVER['SERVER_ADDR'] == '127.0.0.1') usleep(rand(200,1000)*1000);
return $objResponse;
}
|
Thanks,
Andi |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|