Witam, jestem laikiem i proboje sie czegos nauczyc lecz nie potraie polaczyc prostej funkcji ajax z .htaccess.
Link mam stworzony w ten sposob:
<a href="#" onClick="callAHAH('historia.php', 'content', 'Trwa ładowanie strony...')">Historia</a>
zawartosc wrzuca mi do div o id content
Moje pytanie jest takie:
W jaki sposob w .htaccess zrobic by wykonywala sie funkcja ajax i jednoczesnie pojawial sie przyjazny link?
w .htaccess mam tak:
RewriteEngine on
RewriteRule news index.php
RewriteRule historia story.php
po zmianie z w linku z # na historia laduje mi sie strona osobno a nie do div.
Prosze o pomoc.
Dodatkowo jeszcze zawartosc ajax.js:
function getXMLHTTPRequest() {
try {
req=new XMLHttpRequest(); /* np. Firefox */
} catch(err1) {
try {
req=new ActiveXObject("Msxm12.XMLHTTP"); /* niektóre wersje IE */
} catch(err2) {
try {
req=new ActiveXObject("Microsoft.XMLHTTP"); /* niektóre wersje IE */
} catch(err3) {
req=false;
}
}
}
return req;
}
/* WCZYTYWANIE PODSTRON */
var http=getXMLHTTPRequest();
function callAHAH(url, pageElement, callMessage) {
document.getElementById(pageElement).innerHTML = callMessage;
myRand=parseInt(Math.random()*9999999999);
var myurl=url + "?rand=" + myRand;
http.open("GET",myurl,true);
http.onreadystatechange = function() {responseAHAH(pageElement);};
http.send(null);
}
function responseAHAH(pageElement) {
if(http.readyState == 4) {
if(http.status == 200) {
var output = http.responseText;
document.getElementById(pageElement).innerHTML = output;
}
}
}