View Single Post
Old 07-23-2007, 11:59 PM   PM User | #1
StupidRalph
Senior Coder

 
Join Date: Mar 2003
Location: Atlanta
Posts: 1,037
Thanks: 14
Thanked 30 Times in 28 Posts
StupidRalph is on a distinguished road
AJAX and Actionscript

I have a page (genre.php) that has different songs and on this page you can rate each song. I also have a flash mp3 player that pops up in a different window so you can hear each song. Members want the ability to rate songs from the mp3 player. I've already added this functionality to update the DB courtesy of actionscript. The problem I am running into is how can update the main page (genre.php) with the new rating from the mp3 player? I think the problem I am running into is setting the correct image to be updated.

I was going to do this all in flash but I'm using SWFObject to embed the .swf files and its really slow for the page to load since its loading 50 songs per page.

I was thinking of doing something like this...
Code:
//var xmlHttp = create XMLHTTPRequest according to browser
...
xmlHttp.onreadystatechange=function()
  {
  if(xmlHttp.readyState==4)
	{
	document.imgRate.src = xmlHttp.responseText; //how do I target the correct image to change the src??? How should I set 'imgRate' on the left side of the = sign?
	}
  }
xmlHttp.open("POST","updateRate.php",true);
xmlHttp.send(null);
}
When a person clicks the song name I use javascript to launch the mp3 player. Do I use that as an opportunity to pass the imgRate id of the specific song or something?

I've never used AJAX and very minimal javascript experience but I can understand the basics so feel free to use any jargon necessary.

Quote:
Originally Posted by A1ien51
Are you reusing the Object?

The correct order with IE is

open()
onreadystatechange
send()

If you have onreadystatechange before the open, IE will not work.

Eric
I've seen this in another post here...considering the fact that I learned this from w3schools am I coding this wrong as well? (Reference to aforementioned post)

Edit: I didn't want to just post a bunch of unnecessary code. Please tell me if you need to see other code in order to assist me on this situation.

Edit: How do I change the Thread Title as its confusing seeing that I'm not necessarily needing actionscript and AJAX to communicate. Although, if you know of a way to do that, that will be helpful too
__________________
Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.

Last edited by StupidRalph; 07-24-2007 at 12:23 AM..
StupidRalph is offline   Reply With Quote