homepage Welcome to WebmasterWorld Guest from 54.226.0.225
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
Ajax new user - Can't get any respnse
Ajax - no response
colorgaze




msg:4409659
 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).

 

daveVk




msg:4409735
 2:01 am on Jan 23, 2012 (gmt 0)

you need to set xmlhttp

var xmlhttp;
becomes
var xmlhttp = getXHR();

see link below for function getXHR

[webmasterworld.com...]

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved