Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Smarty & Xajax: Template innerhalb eines Divs nachladen

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: German
View previous topic :: View next topic  
Author Message
dostie
Smarty n00b


Joined: 03 Sep 2008
Posts: 3

PostPosted: Wed Sep 03, 2008 10:28 pm    Post subject: Smarty & Xajax: Template innerhalb eines Divs nachladen Reply with quote

Hallo Zusammen,

ich habe eine Frage bzgl. Smarty in Verbindung mit Xajax. Und zwar würde ich gerne innerhalb eines DIVs eines Templates (div id=“layout“, test.tpl) ein bestimmtes weiteres Template (ausgabe.tpl) nachladen.

Folgende Lösung habe ich probiert:

Inhalt test.php


Code:
<?php

require_once('includes/getSmarty.php');

require_once('includes/xajax/xajax_core/xajax.inc.php');
 
$xajax = new xajax();

function changediv($test){
   global $smarty;
   $objResponse = new xajaxResponse();
   
   $html = $smarty->fetch("ausgabe.tpl");
   
   $objResponse->assign("layout","innerHTML",$html);
   return $objResponse;
}
$xajax->registerFunction("changediv");

$smarty->assign('xajax',$xajax->getJavascript('includes/xajax'));
$smarty->display('test.tpl');
?>


Inhalt: test.tpl

Code:
<html>
<head>
                <title>Testseite!</title>
                {$xajax}
</head>
<body>

<input type="button" id="sample" name="sample" onClick="changediv('test');" />

<div id="layout">
hier müsste sich was ändern
</div>

</body></html>


Inhalt: ausgabe.tpl


Code:
Blabla


Leider tut sich leider nichts Crying or Very sad. Jemand eine Idee?

Weitere Informationen:

1) Firebug meldet: “changediv is not defined” … ist sie aber innerhalb der test.php – Ausgabe.

2) Quellcode: Ausgabe der test.php

Code:
<script type="text/javascript" charset="UTF-8">
/* <![CDATA[ */
try { if (undefined == xajax.config) xajax.config = {}; } catch (e) { xajax = {}; xajax.config = {}; };
xajax.config.requestURI = "url.de/test.php";
xajax.config.statusMessages = false;
xajax.config.waitCursor = true;
xajax.config.version = "xajax 0.5 rc1";
xajax.config.legacy = false;
xajax.config.defaultMode = "asynchronous";
xajax.config.defaultMethod = "POST";
/* ]]> */
</script>
<script type="text/javascript" src="includes/xajax/xajax_js/xajax_core.js" charset="UTF-8"></script>
<script type="text/javascript" charset="UTF-8">
/* <![CDATA[ */
window.setTimeout(
 function() {
  var scriptExists = false;
  try { if (xajax.isLoaded) scriptExists = true; }
  catch (e) {}
  if (!scriptExists) {
   alert("Error: the xajax Javascript component could not be included. Perhaps the URL is incorrect?\nURL: includes/xajax/xajax_js/xajax_core.js");
  }
 }, 2000);
/* ]]> */
</script>

<script type='text/javascript' charset='UTF-8'>
/* <![CDATA[ */
xajax_change_color = function() { return xajax.request( { xjxfun: 'change_color' }, { parameters: arguments } ); };
xajax_changediv = function() { return xajax.request( { xjxfun: 'changediv' }, { parameters: arguments } ); };
/* ]]> */
</script>

</head>
<body>

<input type="button" id="sample" name="sample" onClick="changediv('test');" />

<div id="layout">
hier müsste sich was ändern
</div>


</body>
</html>


Vielen Dank und Grüße!


Last edited by dostie on Thu Sep 04, 2008 10:41 am; edited 1 time in total
Back to top
View user's profile Send private message
Celeb
Administrator


Joined: 17 Apr 2007
Posts: 1025
Location: Vienna

PostPosted: Wed Sep 03, 2008 11:21 pm    Post subject: Reply with quote

Versuch mal
Code:
<input type="button" id="sample" name="sample" onClick="xajax_changediv('test');" />

_________________
Darn computers always do what I tell them to instead of what I want them to do.
Back to top
View user's profile Send private message
dostie
Smarty n00b


Joined: 03 Sep 2008
Posts: 3

PostPosted: Thu Sep 04, 2008 8:17 am    Post subject: Reply with quote

Hi,

ah ... guter Punkt! Vielen Dank!

Immerhin ist damit nun die Javascript-Fehlermeldung elemeniert. Allerdings tut sich immer noch nicht wirklich was.

Noch eine Idee wo ich nen Patzer drin habe?

Vielen Dank!
Back to top
View user's profile Send private message
dostie
Smarty n00b


Joined: 03 Sep 2008
Posts: 3

PostPosted: Thu Sep 04, 2008 10:40 am    Post subject: Reply with quote

ich habe jetzt noch mal den debug-mode mit rein genommen:

Output:
Code:


xajax debug output
Thu Sep 04 2008 12:38:16 GMT+0200

DONE [201ms]

Thu Sep 04 2008 12:38:16 GMT+0200

ERROR: No response processor is available to process the response from the server.
Content-Type: text/html.
Check for error messages from the server.

Thu Sep 04 2008 12:38:16 GMT+0200

RECEIVED [status: 200, size: 1912 bytes, time: 199ms]:
<html>
<head>
   <title>Testseite!</title>
   
<script type="text/javascript" charset="UTF-8">
/* <![CDATA[ */
try { if (undefined == xajax.config) xajax.config = {}; } catch (e) { xajax = {}; xajax.config = {}; };
xajax.config.requestURI = "http://url/test.php";
xajax.config.statusMessages = false;
xajax.config.waitCursor = true;
xajax.config.version = "xajax 0.5 rc1";
xajax.config.legacy = false;
xajax.config.defaultMode = "asynchronous";
xajax.config.defaultMethod = "POST";
/* ]]> */
</script>
<script type="text/javascript" src="includes/xajax/xajax_js/xajax_core.js" charset="UTF-8"></script>
<script type="text/javascript" src="includes/xajax/xajax_js/xajax_debug.js" charset="UTF-8"></script>
<script type="text/javascript" charset="UTF-8">
/* <![CDATA[ */
window.setTimeout(
 function() {
  var scriptExists = false;
  try { if (xajax.isLoaded) scriptExists = true; }
  catch (e) {}
  if (!scriptExists) {
   alert("Error: the xajax Javascript component could not be included. Perhaps the URL is incorrect?\nURL: includes/xajax/xajax_js/xajax_core.js");
  }
 }, 2000);
/* ]]> */
</script>
<script type="text/javascript" charset="UTF-8">
/* <![CDATA[ */
window.setTimeout(
 function() {
  var scriptExists = false;
  try { if (xajax.debug.isLoaded) scriptExists = true; }
  catch (e) {}
  if (!scriptExists) {
   alert("Error: the xajax.debug Javascript component could not be included. Perhaps the URL is incorrect?\nURL: includes/xajax/xajax_js/xajax_debug.js");
  }
 }, 2000);
/* ]]> */
</script>

<script type='text/javascript' charset='UTF-8'>
/* <![CDATA[ */
xajax_changediv = function() { return xajax.request( { xjxfun: 'changediv' }, { parameters: arguments } ); };
/* ]]> */
</script>

</head>
<body>

<input type="button" id="sample" name="sample" onClick="xajax_changediv();" />

<div id="layout">

</div>

<div id="divix">
xajax
</div>

</body>
</html>

Thu Sep 04 2008 12:38:15 GMT+0200

SENT [35 bytes]

Thu Sep 04 2008 12:38:15 GMT+0200

SENDING REQUEST

Thu Sep 04 2008 12:38:15 GMT+0200

CALLING:
xjxfun: changediv
URI:
http://url.de/test.php

Thu Sep 04 2008 12:38:15 GMT+0200

POST: xjxfun=changediv
&xjxr=1220524695876

Thu Sep 04 2008 12:38:15 GMT+0200

INITIALIZING REQUEST OBJECT

Thu Sep 04 2008 12:38:15 GMT+0200

PREPARING REQUEST

Thu Sep 04 2008 12:38:15 GMT+0200

PROCESSING PARAMETERS [0]

Thu Sep 04 2008 12:38:15 GMT+0200

INITIALIZING REQUEST

Thu Sep 04 2008 12:38:15 GMT+0200

STARTING XAJAX REQUEST
Back to top
View user's profile Send private message
Celeb
Administrator


Joined: 17 Apr 2007
Posts: 1025
Location: Vienna

PostPosted: Fri Sep 05, 2008 7:10 am    Post subject: Reply with quote

Ah ja .. die Fehlermeldung hilft schon:
Quote:
ERROR: No response processor is available to process the response from the server.

Code:
xajax.config.requestURI = "url.de/test.php";

In dieser Variable steht, and welche URL der AJAX Request gesendet wird. In diesem Script muss das stehen (ich glaube noch bevor irgend etwas anderes ausgegeben wird):
Code:
$xajax->processRequest();

Ich teile meine xajax Anwendungen meistens in drei Teile auf:
  • foo.php - Die Seite der Anwendung. Xajax-technisch wird hier nur die common Datei inkludiert und das xajax-Javascript ausgegeben.
  • foo.xajax_server.php - Definition der Xajax Funktionen, processRequest()
  • foo.xajax_common.php - Hier werden alle Tasks durchgeführt, die sowohl beim ersten Laden der Seite als auch beim Xajax Request nötig sind: Include der xajax.inc.php, Konfiguration, registerFunction() Aufrufe ...
Die Idee kommt allerdings nicht von mir, ich habe das irgendwann im xajax Wiki oder so gelesen.
_________________
Darn computers always do what I tell them to instead of what I want them to do.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: German All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP