- Joined
- May 8, 2013
- Posts
- 2,515
- Reaction score
- 859
Hi All,
I tried to sort this ages ago but never did so getting back to it. Basically.... i'm trying to pass the track name from a soundcloud widget to a php mail script. Now within the html page I know the variable is defined as I can alert it fine and it shows correctly. However, ive tried a few thing to pass to a php mail script (the mailer works fine) but it always comes out as 'undefined' on the mail itself , so its not passing.I'm not a coder at all really so it's all done by search and working out, but i'm guessing it has something to do with scope. I thought if i defined the variable outside a function it makes it global ? But its not working.
Anyhoo.... here's what i have for the initial load page
The alert works fine. I had then tried passing the variable as a 'post' parameter to the mailer script but comes out as undefined. Any pointer greatly appreciated.
I tried to sort this ages ago but never did so getting back to it. Basically.... i'm trying to pass the track name from a soundcloud widget to a php mail script. Now within the html page I know the variable is defined as I can alert it fine and it shows correctly. However, ive tried a few thing to pass to a php mail script (the mailer works fine) but it always comes out as 'undefined' on the mail itself , so its not passing.I'm not a coder at all really so it's all done by search and working out, but i'm guessing it has something to do with scope. I thought if i defined the variable outside a function it makes it global ? But its not working.
Anyhoo.... here's what i have for the initial load page
HTML:
//i frame embed of track
<iframe id="sc-widget" width="100%" height="450" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=track url here"></iframe>
// load api from soundcloud
<script src="https://w.soundcloud.com/player/api.js" type="text/javascript"></script>
<script type="text/javascript">
// define var for sending
var trackName;
(function(){
var widgetIframe = document.getElementById('sc-widget'),
widget = SC.Widget(widgetIframe);
widget.bind(SC.Widget.Events.READY, function() {
widget.bind(SC.Widget.Events.PLAY, function() {
// get information about currently playing sound
widget.getCurrentSound(function(currentSound) {
trackName=currentSound.title;
alert(trackName);
});
});
The alert works fine. I had then tried passing the variable as a 'post' parameter to the mailer script but comes out as undefined. Any pointer greatly appreciated.