Welcome to WebmasterWorld Guest from 184.73.13.66

Forum Moderators: open

Message Too Old, No Replies

Ajax new user - Can't get any respnse

Ajax - no response

   
5:56 pm on Jan 22, 2012 (gmt 0)



I am trying to set Ajax up for a media server (hosting professor lectures).
I am trying to update my mysql, if someone likes a particular lecture.

However, I am not able to get any response what so ever. I am using an onclick - however, nothing happens. Check the code below - I have set up an if-else, with onreadyState, and for both the conditions (exhaustive), no change happens. Please suggest what I am doing wrong.



function show_jw()
{
var filepath=jwplayer('container').getPlaylistItem().file;
var xmlhttp;

xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("like").innerHTML="file found";
}
else
{
document.getElementById("like").innerHTML="file not found";
}
}
xmlhttp.open("GET","ajaxphp.php?f="+filepath,true);
xmlhttp.send();
}
</script>

<input type="button" onclick=show_jw() value="like" />


on clicking the button, I should either see "file found" or "file not found". I see nothing (on chrome or firefox).
2:01 am on Jan 23, 2012 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



you need to set xmlhttp

var xmlhttp;
becomes
var xmlhttp = getXHR();

see link below for function getXHR

[webmasterworld.com...]