Use values from one javascript function into another

AJ152

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>
Sterling Archer

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Change javascript value in one function from another javascript function programmatically

From Dev

Passing two values from one Matlab function to another in one line

From Dev

How to Map Array values from one Array to Another Array JavaScript?

From Dev

Passing values from one function to another function

From Dev

How to use data from one function in another function

From Dev

How to use values from one data frame to inform a summing function within another data frame in R?

From Dev

Python: Use returned values from a function to another function

From Dev

How to use join to link values from one table to another

From Dev

how to return multiple values from an asynchronous function to use in another function

From Dev

How to use data from one function in another function?

From Dev

How to pass values from one page to another by onclick in javascript?

From Dev

send a mouse over event from one function to another function in javascript

From Dev

Send values from one PHP file to another with JavaScript/AJAX

From Dev

How to use array from one function, inside another function

From Dev

Pass Dynamic Values from one function to another function in class

From Dev

How to use output values of one function as input of another MATLAB

From Dev

use info from one function to another

From Dev

How to use itertools to pass the returned values from one function to another?

From Dev

Use a variable from one function within another function with Python

From Dev

Accessing variables from one function to another in JavaScript

From Dev

Subtracts values one list from another in javascript

From Dev

How to use values from one keyword to another keyword in robot framework

From Dev

Use values from one row SELECT TOP 1 in another query

From Dev

Passing values from one function to another with React navigation 5

From Dev

Use variable of one function in another (Three.js) Javascript

From Dev

Javascript move selected option with multiple values from one list to another

From Dev

Use values from one table as keys in another (PHP)

From Dev

Unable to return variable from one function and use it in another function

From Dev

How to use values ​from one module script in another module script?

Related Related

  1. 1

    Change javascript value in one function from another javascript function programmatically

  2. 2

    Passing two values from one Matlab function to another in one line

  3. 3

    How to Map Array values from one Array to Another Array JavaScript?

  4. 4

    Passing values from one function to another function

  5. 5

    How to use data from one function in another function

  6. 6

    How to use values from one data frame to inform a summing function within another data frame in R?

  7. 7

    Python: Use returned values from a function to another function

  8. 8

    How to use join to link values from one table to another

  9. 9

    how to return multiple values from an asynchronous function to use in another function

  10. 10

    How to use data from one function in another function?

  11. 11

    How to pass values from one page to another by onclick in javascript?

  12. 12

    send a mouse over event from one function to another function in javascript

  13. 13

    Send values from one PHP file to another with JavaScript/AJAX

  14. 14

    How to use array from one function, inside another function

  15. 15

    Pass Dynamic Values from one function to another function in class

  16. 16

    How to use output values of one function as input of another MATLAB

  17. 17

    use info from one function to another

  18. 18

    How to use itertools to pass the returned values from one function to another?

  19. 19

    Use a variable from one function within another function with Python

  20. 20

    Accessing variables from one function to another in JavaScript

  21. 21

    Subtracts values one list from another in javascript

  22. 22

    How to use values from one keyword to another keyword in robot framework

  23. 23

    Use values from one row SELECT TOP 1 in another query

  24. 24

    Passing values from one function to another with React navigation 5

  25. 25

    Use variable of one function in another (Three.js) Javascript

  26. 26

    Javascript move selected option with multiple values from one list to another

  27. 27

    Use values from one table as keys in another (PHP)

  28. 28

    Unable to return variable from one function and use it in another function

  29. 29

    How to use values ​from one module script in another module script?

HotTag

Archive