Ajaxified page, help needed to improve code
$30-50 USD
Paid on delivery
I have put together some code from various sources but javascript is somewhat unknown to me and I only seem to fail with the code I have so far..
What I want to do is convert every normal link on the page to ajax links and load the pages through ajax.
So far I only succeeded to transform the links from the initial page and load the content in a div. The problem is I don't have access to the content is loading in the div and the new content still has normal links instead of ajax.
What I need help for is:
The Home page holds the menu and content div.
-I want to convert the new links within the content loaded in the div, every time the div changes.
-Also if the user clicks on the home button in the menu, it will load the content of index along with this script, and everything will become a loop. Find a way to prevent loading the home page in the div, and paste instead a custom text.
-Add a loading gif and animate the load (fast fade)
If you suspect any other problems it may occur from this code can you please advice me what to change?
This is the code I have so far..
Inserted in the head tag:
<script type="text/javascript">
var xmlhttp;
if([login to view URL]) { xmlhttp=new XMLHttpRequest(); }
else if([login to view URL]){ xmlhttp=new ActiveXObject("[login to view URL]"); }
else{ }
xmlhttp.onreadystatechange=function(){
if(xmlhttp.readyState==4)
{ [login to view URL]("contentarea").innerHTML = [login to view URL]; }
else{ [login to view URL]("contentarea").innerHTML = ""; }
}
function loadPage(url){
[login to view URL]("contentarea").innerHTML = "";
[login to view URL]("GET",url,true);
[login to view URL](null);
}
</script>
Inserted somewhere in the body:
<div id="contentarea"></div>
Inserted right before the body ends:
<script>
var oP = [login to view URL]("a");
var ctr=0;
while(ctr < [login to view URL]){
var oldHref = [login to view URL]("a")[ctr].href;
[login to view URL]("a")[ctr].href="javascript:loadPage('"+oldHref+"');";
ctr++;
}
</script>
Project ID: #1521994
About the project
6 freelancers are bidding on average $46 for this job
Hi, I have read your complete statement and I have faced the same problem many weak ago. I can complete this work. Waiting for a positive response. Thank you.