Jump to content

Help with running javascript on PHP loaded with AJAX


KUKayaker

Recommended Posts

I need assistance with loading javascript on a page loaded by an ajax function.  The function works correctly for other pages but on this particular page I'm loading a flash mp3 player.  When I open that page directory I see the player but when I load it through ajax I just get the original div that should be replaced.  In further testing I noticed that no inline javascript seems to load so for example if I load a php page with the following code:

 

<script type="text/javascript">
alert("test");
</script>

 

It doesn't trigger.  The code on the page I'm trying to load is below:

<script type="text/javascript" src="Player/swfobject.js"></script>
<div id="flashPlayer">
  This text will be replaced by the flash music player.
</div>

<script type="text/javascript">
alert("test");
   var so = new SWFObject("Player/playerMultipleList.swf", "mymovie", "295", "200", "7", "#FFFFFF");  
   so.addVariable("autoPlay","no")
   so.addVariable("playlistPath","MP3Playlist.php")
   so.write("flashPlayer");
</script>

 

I assume this is a really common problem I just wasn't able to find what I was looking for in searching.  Thanks for any help in advance.

It doesn't load because AJAX doesn't parse JS.  It's job is to retrieve remote data, not retrieve and process remote data.

 

 

You can either eval() it, or you can use some other method.  (A framework with parsing capabilities, or having it fire off a function on the page that requests the second page.)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.