J'ai le code ci-dessous, qui travaillait auparavant bien:les variables ajax php javascript
var xmlHttp
var layername
var url
function update(layer, url) {
var xmlHttp=GetXmlHttpObject(); //you have this defined elsewhere
if(xmlHttp==null) {
alert("Your browser is not supported?");
}
xmlHttp.onreadystatechange = function() {
if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
document.getElementById(layer).innerHTML=xmlHttp.responseText;
} else if (xmlHttp.readyState==1 || xmlHttp.readyState=="loading") {
document.getElementById(layer).innerHTML="loading";
}
//etc
}
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function updateByPk(layer, pk) {
url = "get_auction.php?cmd=GetAuctionData&pk="+pk+"&sid="+Math.random();
update(layer, url);
}
function updateByQuery(layer, query) {
url = "get_records.php?cmd=GetRecordSet&query="+query+"&sid="+Math.random();
update(layer, url);
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
xmlHttp=new XMLHttpRequest();
}catch (e)
{
try
{
xmlHttp =new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {}
}
return xmlHttp;
}
function makewindows(){
child1 = window.open ("about:blank");
var phpstring = <?php $out = htmlspecialchars(json_encode($row2['ARTICLE_DESC']), ENT_QUOTES); echo("'$out'"); ?>;
child1.document.write(phpstring);
//child1.document.write("<?php echo htmlspecialchars(json_encode($row2['ARTICLE_DESC']), ENT_QUOTES); ?>");
child1.document.close();
}
La partie qui commeneted sur fonctionnait très bien dans une version previus, dans ce javascript remplaçais row2 [ 'ARTICLE_DESC '], une variable php avec le contenu de la variable. Ce fichier javascript est inclus à partir d'une balise de script dans un fichier php, et a toujours bien fonctionné. Je l'ai changé quelque chose récemment, cependant, je ne suis pas sûr de ce que la chose était spécifique, butnow-je obtenir ces erreurs, de Firebug:
function makewindows(){
child1 = window.open ("about:blank");
child1.document.write("<br />
<b>Notice</b>: Undefined variable: row2 in <b>C:\Programme\EasyPHP 2.0b1\www\records4\fetchlayers.js</b> on line <b>57</b><br />
null");
child1.document.close();
}
chaîne non terminée sur la ligne 57 et la updateByQuery n'est pas défini.
Je ne sais pas pourquoi je reçois l'une de ces erreurs, et pourquoi updateByPk ne renvoie pas d'erreur. Je suis encore plus confus quant à l'extension d'article_Desc et comment. Cela se passe sur l'index.php, qui a un lien pour appeler updateByQuery, qui chargerait une section via ajax qui aurait un lien vers updateByPk, qui afficherait la section finale, qui aurait un lien vers makewindows(), où l'article_Desc se rapportent à la $ pk pertinente
Tout cela fonctionnait bien, et je ne peux pas savoir pourquoi il ne l'est plus.
serait-il utile si je devais coller les fichiers php quelque part?
modifier. Je ne comprends pas pourquoi cela se produit, mais j'ai essayé de modifier la fonction de sorte qu'il prenne un paramètre.
function makewindows(html){
child1 = window.open ("about:blank");
child1.document.write(html);
child1.document.close();
}
conjointement avec thse deux extraits de php
$html = json_encode(htmlspecialchars($row2['ARTICLE_DESC']));
et
<a href='#' onclick='makewindows(/"".$html."/"); return false;'>Click for full description </a></p>
Si vous pensez que ma réponse est correcte, merci de la valider. Merci;) – fromvega