Read Data from text file on server using $.ajax to call a php script
<p>This is my first time posting on this site. I have looked over several of the previous postings related to this topic, but did not find anything that works for me. I am trying to use javascript and jquery $.ajax to call a php script on the server and return the contents of the file. Thus far I am not getting any data back. I am able to update the .txt file on the server using the $.ajax, but could use some help in finding out what I am doing wrong to retrieve it. I do not see any errors being generated from the php script and the events.txt file is not blank. vb.net and c# are my native languages so this is a bit foreign to me.</p>

<p>My js is:</p>

<pre><code>function readText() {
        var url = "readdata.php";
        var result = "";
        $.ajax({
            url: url,
            type: 'get',
            dataType: 'text',
            success: function (data) {
                result = data;
                alert(result);
            },
            async: false
        });
    }
</code></pre>

<p>and my readdata.php script is:</p>

<pre><code>&lt;? 
$file=fopen("events.txt","r");
$read=fread($file,filesize("events.txt"));
fclose($file); 
echo $read;
?&gt;
</code></pre>

<p>Any advise is welcome. Thanks!</p>
