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"> <head> <title>jCarousel Examples </title> <!-- Ajax - getdata(); --> </head> <body> <div id="wrap"> <div id="imagePane> </div> <a href="#" onclick="getdata('../obrazki/1.jpg','imagePane');"> </div> </body> </html>
// 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 */ } // 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; }