Friday 17 October 2008 1:48:35 am
hello, i have a file in .../design/admin/templates/node/view/mytempltes.tpl. in this file i have this code :
{def $articles=fetch(content,list,hash(parent_node_id,2,
class_filter_type,include,
class_filter_array,array('myarticle')
)
)
}
<form method="post" action={'content/action'|ezurl()}>
<select name="choix" id="monchoix" onchange="recup_choix_select()">
<option >choisir une news</option>
{foreach $articles as $child}
<option value="{$child.node_id}">{$child.name|wash()} {$child.object.id} </option>
{/foreach}{undef $articles}
</select>
</form>
the functions recup_choix_select()
send the selected value by ajax and load the file located in the same directory .../design/admin/templates/node/view/callajax.tpl. but the loaded file is the pagelayout.tpl located in the admin directory not the callajax.tpl. the definition of the recup_choix_select function is:
function recup_choix_select(){
var xmlhr = null;
if(window.XMLHttpRequest){// compatible Firefox ,opera et autres
xmlhr = new XMLHttpRequest();
}
else if(window.ActiveXObject){ // compatible Internet Explorer
try {
xmlhr = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
xmlhr = new ActiveXObject("Microsoft.XMLHTTP");
}
}
else { // XMLHttpRequest non supporté par le navigateur
alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
xmlhr = false;
}
xmlhr.onreadystatechange= function(){
if(xmlhr.readyState == 4 && xmlhr.status == 200){
resultat=xmlhr.responseText;
document.getElementById("contenu_ajax").innerHTML=resultat;
}
}
var choix=
document.getElementById("monchoix").options[document.getElementById("monchoix").selectedIndex].value;
xmlhr.open("post","callajax.tpl",true);
xmlhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
xmlhr.send("ident="+choix);
}
i would like to know why the callajax.tpl it didn't loaded. the same code run wery good in an xhtml file. thanks in advance.
The theory is when we know everything and nothing works.
The practice is when everything works and nobody knows why.
If the practice and theory are met, nothing works and we do not know why.
Albert Einstein
|