Ajaxified page, help needed to improve code

In Progress Posted Mar 23, 2012 Paid on delivery
In Progress 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>

AJAX jQuery / Prototype

Project ID: #1521994

About the project

6 proposals Remote project Active Mar 28, 2012

6 freelancers are bidding on average $46 for this job

canlan318

Dear sir. I sent you a private message. Please check it. Regards.

$50 USD in 1 day
(56 Reviews)
6.3
kharota

Ready to do it now. please check your pmb.

$50 USD in 2 days
(23 Reviews)
4.7
freelancer4142

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.

$50 USD in 1 day
(0 Reviews)
0.0
hitesh234

please check pmb.

$30 USD in 0 days
(0 Reviews)
0.0
ankitd1

Hi, I am an expert in Jquery, Javascript and ASP .NET.

$50 USD in 5 days
(0 Reviews)
0.0