abrir pagina numa div com link + ajax
oi pessoa ja não sei mais o que fazer
o grande pro é minha falta de conhecimento do assunto:
acredito que este fácil pra vocês.
<?php header("Content-Type: text/html; charset=ISO-8859-1",true) ?><?php include "bdscripts/init.php"; ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">](http://www.w3.org/1999/xhtml) <script type="text/javascript" language="JavaScript"> /////////////////////////////////////////////////////////////////////////////////////// //Tenta criar o objeto xmlHTTPtry{ xmlhttp = new XMLHttpRequest();}catch(ee){ try{ xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }catch(e){ try{ xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }catch(E){ xmlhttp = false; } }}//Fila de conexõesfila=[]ifila=0//Carrega via XMLHTTP a url recebida e coloca seu valor//no objeto com o id recebidofunction ajaxHTML(id,url){ //Carregando... document.getElementById(id).innerHTML="<span class='carregando'>"+ "Carregando...</span>" //Adiciona à fila fila[fila.length]=[id,url] //Se não há conexões pendentes, executa if((ifila+1)==fila.length)ajaxRun()}//Executa a próxima conexão da filafunction ajaxRun(){ //Abre a conexão xmlhttp.open("GET",fila[ifila][1],true); //Função para tratamento do retorno xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4){ //Mostra o HTML recebido retorno=unescape(xmlhttp.responseText.replace(/\+/g," ")) document.getElementById(fila[ifila][0]).innerHTML=retorno //Roda o próximo ifila++ if(ifila<fila.length)setTimeout("ajaxRun()",20) } } //Executa xmlhttp.send(null)} // utilizo esta função recebendo o valor do camopo de formulário conforme sua id. beleza // mas agora quero quero fazer através do link como faço para pegar o valor. function getfoto(){ cod_foto = document.getElementById("<?=$_GET['id'];?>").value; ajaxHTML("apresenta","getfoto.php?cod_foto=" + cod_foto); }</script><style type="text/css">#thumb {border:2px solid #0000CC;width:100px;background:$eeeeee;overflow:auto;padding:10px;height:350px;margin: 10px 10px 0px 10px;}#thumb ul{list-style:none;}#thumb ul li{background:#FFFFFF;width:auto;height:auto;padding:5px;border:2px solid #0000CC;margin:3px;}#thumb ul li img {border:2px solid #666666;margin:0px;padding:0px;}#apresenta {border:2px solid #0000CC;width:320px;background:$eeeeee;padding:10px;height:350px;margin:10px}</style><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Documento sin título</title></head><body><table width="100%%" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="2">Foto</td> </tr> <tr> <td> <div id="thumb"> <ul> <?php$cod_anun = "1";Abre_Conexao();$ac1 = mysql_query("select * from foto_anuncios wherecod_anun='$cod_anun'") or die (mysql_error());@mysql_close();while ($rsAC = mysql_fetch_array($ac1)){?>//enviar id e valor não estou conseguindo <li><a href="#" onclick="getfoto(this.id)" id="<?=$rsAC['cod_foto'];?>"> <img src="img_user/thumbs/<?=$rsAC['foto_anun'];?>" title="<?=$rsAC['titulo_foto_anun'];?>"/></a></li> <? } ?> </ul> </div> </td> <td>//VOU RECEBER A PAGINA GETFOTO NESTA DIV ABAIXO <div id="apresenta"> </div> </td> </tr> <tr> <td> </td> <td> </td> </tr></table></body></html>
PAGINA QUE GERA O RESULTADO NA DIV ID="APRESENTA"
<?php header("Content-Type: text/html; charset=ISO-8859-1",true) ?><?php include "bdscripts/init.php"; include "bdscripts/contador.php"; ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">](http://www.w3.org/1999/xhtml)<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Documento sin título</title></head><?php$cod_foto = isset($_GET["cod_foto"]) ? $_GET["cod_foto"] : 0; Abre_Conexao(); $rs_foto = mysql_query("SELECT * FROM foto_anuncios WHERE cod_foto = '$cod_foto'") or die ("Erro Estasdos: ". mysql_error()); @mysql_close(); ?><table width="100%%" border="0" cellspacing="0" cellpadding="0"> <tr> <td bgcolor="#eeeeee"><h1><?=$rs_foto['titulo_foto_anun'];?></h1></td> </tr> <tr> <td><img src="<?=$rs_foto['foto_anun'];?>" title="Connect Anúncios - <?=$rs_foto['titulo_foto_anun'];?>"/></td> </tr> <tr> <td bgcolor="#eeeeee"><p align="justify"><?=$rs_foto['desc_foto_anun'];?></p></td> </tr></table><body></body></html>
dESDE JA AGRADEÇO A COLABORAÇÃO
Discussão (5)
Carregando comentários...