I realize this is not really a yii problem but has anyone come across this before? I’m using an ajax function to refresh a div every X seconds. I’m getting this error upon refresh of the div.
Access forbidden!
You don’t have permission to access the requested object. It is either read-protected or not readable by the server.
I should add, I’m running the xampp server as localhost and I’m using mac osx. The file in question, the updatedLoggedInList.php file, is in the same directory as the php file containing the ajax function below. I was originally getting a cannot find error but I changed the file path in the function and it now see’s the file, just can’t access it.
below is the ajax function
<script type="text/javascript">
function ajaxFunction(){
var ajaxRequest; // The variable that makes Ajax possible!
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
var list = document.getElementById('userList');
if(ajaxRequest.readyState == 4){
list.innerHTML = ajaxRequest.responseText;
}
}
ajaxRequest.open("GET", "protected/views/room/updatedLoggedInList.php", true);
ajaxRequest.send(null);
}
</script>
<script type="text/javascript">
setInterval(function() {ajaxFunction();}, 5000);
</script>
Is it in anyway possible that something in my php.ini or other type of config file might be restricting access to the url or the original file I was looking for?
I think it might be because the URL being requested is inside the protected folder, and I guess I’m not allowed access anything in that folder from outside. Any way around that?
Sorry kokomo, I should have mentioned that I’d already tried that. That was my first approach, and this is where I started getting the object not found error. Only after I’d appended the Url with /protected/controllers/ could it find the Url, but then as I’ve said, I got the 403 error. I really appreciate your input though, would be such a relief if I could get this resolved.
I think I may have cracked it!! Don’t all requests have to go thru index.php? I added index.php?=r to the Url and now the ajax function seems to be working. Not sure if that’s the best way to do it though, but for now it will have to do. Thanks a million for your input.