Tema: PHP en AJAX
Ver Mensaje Individual
  #1 (permalink)  
Antiguo 14/10/2008, 15:47
oscarguillermofb
 
Fecha de Ingreso: septiembre-2008
Mensajes: 2
Antigüedad: 16 años, 2 meses
Puntos: 0
PHP en AJAX

Hola tengo el siguiente inconveniente:

Mi sitio web cuenta con paginas:

Pagina: index.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Ajax Simple Tabs By www.developersnippets.com</title>
<link rel="stylesheet" type="text/css" href="tabs.css" media="screen">

<script type="text/javascript" src="ajax.js" language="JavaScript"></script>

</head>

<body onload="activeTab(1);">
<div style="display: block;padding:10px;background-color:#dae6fa" id="div6" >
<ul id="tabmenu" >
<li onClick="activeTab(1)"><a class="" id="tab1">Upcoming Events</a></li>
<li onClick="activeTab(2)"><a class="" id="tab2">Events Gallery</a></li>
<li onClick="activeTab(3)"><a class="" id="tab3">Mark Your Calender</a></li>
</ul>
<div id="content"></div>
</div>
</body>
</html>


Pagina: contentpage1.php

<? echo "Texto de prueba"; ?>


Script: ajax.js

/************************************************** ******************************************/
/* AJAX Simple Tabs by developersnippets, This code is intended for practice purposes. */
/* You may use these functions as you wish, for commercial or non-commercial applications, */
/* but please note that the author offers no guarantees to their usefulness, suitability or */
/* correctness, and accepts no liability for any losses caused by their use. */
/************************************************** ******************************************/

var req;
function callPage(pageUrl, divElementId, loadinglMessage, pageErrorMessage) {
document.getElementById(divElementId).innerHTML = loadinglMessage;
try {
req = new XMLHttpRequest(); /* e.g. Firefox */
} catch(e) {
try {
req = new ActiveXObject("Msxml2.XMLHTTP"); /* some versions IE */
} catch (e) {
try {
req = new ActiveXObject("Microsoft.XMLHTTP"); /* some versions IE */
} catch (E) {
req = false;
}
}
}
req.onreadystatechange = function() {responsefromServer(divElementId, pageErrorMessage);};
req.open("GET",pageUrl,true);
req.send(null);
}

function responsefromServer(divElementId, pageErrorMessage) {
var output = '';
if(req.readyState == 4) {
if(req.status == 200) {
output = req.responseText;
document.getElementById(divElementId).innerHTML = output;
} else {
document.getElementById(divElementId).innerHTML = pageErrorMessage+"\n"+output;
}
}
}

/* This Function is for Tab Panels */
function activeTab(tab)
{
document.getElementById("tab1").className = "";
document.getElementById("tab2").className = "";
document.getElementById("tab3").className = "";
document.getElementById("tab"+tab).className = "active";
if(tab == 1) // If your tabs are more, then you can use 'switch' condition instead of 'if' condition for better practice
{callPage('contentpage1.php', 'content', '<img src=\"images/loading.gif\" /> Content is loading, Please Wait...', 'Error in Loading page <img src=\"images/error_caution.gif\" />');
}else if(tab == 2){
callPage('contentpage2.php', 'content', '<img src=\"images/loading.gif\" /> Content is loading, Please Wait...', 'Error in Loading page <img src=\"images/error_caution.gif\" />');
}else
callPage('contentpage3.php', 'content', '<img src=\"images/loading.gif\" /> Content is loading, Please Wait...', 'Error in Loading page <img src=\"images/error_caution.gif\" />');
}


El probema radica en que el ajax.js no me permite mostrar las paginas con extension .php sino solo .html .htm .shtml Estimados amigos que debo modificar para que muestre tambien las paginas con extension .php..