Witam.
Chcę aby po kliknięciu zdjęcia miniaturki załadował się większy obrazek. Chcę to zrobić przy pomocy ajaxowej funkcji getdata(). Problem w tym, zę po kliknięciu w miniaturkę ukazują się tzw. "krzaki" zamiast zdjęcia. Jak to wykonać poprawnie?
<!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" xml:lang="en-us"> <title>jCarousel Examples
<!--
Ajax - getdata();
-->
<script type="text/javascript" src="../lib/ajax.js"></script> <a href="#" onclick="getdata('../obrazki/1.jpg','imagePane');"> <img src="../miniaturki/thumb_1.jpg"></a>
// here we define global variable
var ajaxdestination="";
function getdata(what,where) { // get data from source (what)
try {
xmlhttp = window.XMLHttpRequest?new XMLHttpRequest():
new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) { /* do nothing */ }
document.getElementById(where).innerHTML ="
<center><img src='loading.gif'></center>";
// we are defining the destination DIV id, must be stored in global variable (ajaxdestination)
ajaxdestination=where;
xmlhttp.onreadystatechange = triggered; // when request finished, call the function to put result to destination DIV
xmlhttp.open("GET", what);
xmlhttp.send(null);
return false;
}
function triggered() { // put data returned by requested URL to selected DIV
if (xmlhttp.readyState == 4) if (xmlhttp.status == 200)
document.getElementById(ajaxdestination).innerHTML =xmlhttp.responseText;
}
Ten post edytował pirates21 4.08.2011, 13:42:47