I need a little hand here, both this javascript functions are working properly, but I need a value from the first script, so I can "POST" it, but I can't figure out how to make the (string[3]) value to show on the second script and therefore use it.
The only function of this first script is to get values from the getsong.php file
<script type="text/javascript">
var string[3]{
$(document).ready(function(){
$("#jquery_jplayer_1").jPlayer({
ready: function () {
var data = $.ajax({
url: "getsong.php",
async: false
}).responseText;
string = data.split('|');
$(this).jPlayer("setMedia", {
mp3: string[0]
}).jPlayer("play");
$('ol#one').html(string[1]);
$('ol#two').html(string[2]);
$('ol#three').html(string[3]);
},
ended: function (event) {
var data = $.ajax({
url: "getsong.php",
async: false
}).responseText;
string = data.split('|');
$(this).jPlayer("setMedia", {
mp3: string[0]
}).jPlayer("play");
$('ol#one').html(string[1]);
$('ol#two').html(string[2]);
$('ol#three').html(string[3]);
},
swfPath: "js",
supplied: "mp3"
});
});
Then the only function is second script to post to the "update_db.php" with a value from (string[3]) from the script above, and also is reloading the page at the same time. I need the value in the 'STRING[3] GOES HERE' area.
$(function() {
$("#submit01").click(function() {
var song_id = $("#song_id").val();
var dataString = 'song_id='+ 'STRING[3] GOES HERE';
if(song_id=='')
{
$('.success').fadeOut(200).hide();
$('.error').fadeOut(200).show();
}
else
{
$.ajax({
type: "POST",
url: "update_db.php",
data: dataString,
success: function timedRefresh(timeoutPeriod) {
setTimeout("location.reload(true);","0");
}
});
}
return false;
});
});
/////
}
</script>
Place var string
above the line:
$("#jquery_jplayer_1").jPlayer({
And remove var
from
var string = data.split('|');
You can now access string
in any function you want.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments