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.

Link to comment
Share on other sites

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.)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.