Hi frnds,

I am a newbie to AJAX.The task is I have to get the data from a php file and store it in a javascript variable. I have gone through many examples but didn't find helpful.
I am giving a pseudo html code here:

<html>
<head>
<script>
function ajaxfunction()
{
//code for httprequest
call the php file
declare a variable and get the response of php
//return the variable
}
</script>
</head>
<body>
//my code for displaying a map
mainvariable=ajaxfunction();//storing the value of subvariable(data from php) in mainvariable
//use the mainvariable and do the remaining task
<body>
</html>


My php code:
<?php
$file=fopen("datapoints.txt","r");
$read=fread($file,filesize("datapoints.txt"));
fclose($file);
echo $read;
?>

the problem here is I dont have any form variables in my html file to use while calling php file. simply when the page loads, "ajaxfunction()" should be called and get data from php and store in a variable................

I guess you can understand my problem

Any help is greatly appreciated