0

in html page i have script:

<script type="text/javascript" src="player.js"></script>
<head>
    <script>
     $radioURL = "90.100.100.10";
     $radioPort = "8000/xxx;
    </script>
</head>
....

in javascript(player.js), i have:

//get current song
        $.ajaxSetup({ cache: false });
        var dataString = {
        'currentradiourl' : $radioURL,
        'currentradioport' : $radioPort,
      };  
      $.ajax({
        type: "POST",
        url: "song.php",
        data: dataString,
        success: function(data)...

and finally, in php file (song.php) i need to replace code, and call variable from script from html page or javascript file:

$t = new streaminfo('http://90.100.100.10:8000/xxx');

with

$t = new streaminfo('http://'+$radioURL+':'+$radioPort');

Please help!!!... how to proceed?

petro
  • 1
  • 2
  • *"i need to **replace** code"*, what **code** do you **mean** *?????* **???** *?????* –  Oct 24 '16 at 16:28
  • Please paste the contents of the file `song.php` – ka_lin Oct 24 '16 at 16:30
  • the script is hire: [link](http://stackoverflow.com/questions/15803441/php-script-to-extract-artist-title-from-shoutcast-icecast-stream) – petro Oct 24 '16 at 16:45
  • I think you should try to understand the difference between server and browser, what requests are etc. It seems like you have absolutely no idea what those things are and it's just impossible to help you without such basic knowledge. – Mike Szyndel Oct 27 '16 at 11:54
  • Mike Szyndel, sorry, but I got an immediate response, so thousands of thanks to those who helped. Who mastered the language well (and there are many here) replied, without giving details of the script but only what is necessary. I do not claim to be an expert, otherwise I would not have asked for help !!! I do not think it was moral if you do me if you can help well, if not, no! Thank you! – petro Oct 27 '16 at 16:06

2 Answers2

0

In your song.php you are almost right.
Merely use the data you received by POST... and use PHP string concatenation instead of Javascript one :)

$radioURL = isset($_POST['currentradiourl') ? $_POST['currentradiourl' : '';
$radioURL = isset($_POST['currentradioport') ? $_POST['currentradioport' : '';
$t = new streaminfo('http://' . $radioURL . ':' . $radioPort);
cFreed
  • 4,404
  • 1
  • 23
  • 33
0

Since it's a post and you're posting the variables: currentradiourl and currentradioport. In your PHP file you can do this:

$radioURL = $_POST['currentradiourl'];
$radioPort = $_POST['currentradioport'];

$t = new streaminfo("http://{$radioURL}:{$radioPort}");
odannyc
  • 717
  • 9
  • 25