0

I want to print a variable auth in the flashplayer.

For example:

var auth = x1c0de;

mplayer("content").setup({
  playlist: [{
    sources: [{
      file: 'http://dnswebsite.tld/appz?UserSign="I WANT MY auth VAR HERE"/playpath',
    }]
  }],
});
1
  • 2
    Is x1c0de supposed to be a string? Search for "string concatenation". Commented Oct 1, 2014 at 23:39

1 Answer 1

1
file: 'http://dnswebsite.tld/appz?UserSign="' + auth + '"/playpath'

Is this what you're looking for ?

I'm confused by the simplicity of this... I must have missed something.

EDIT:

This is the snippet you gave me in your comment:

$.ajax({
    url: your_url,
    type: 'GET',
    success: function (res) {
        var text = res.responseText;
        var auth = text.match("BEGIN(.*)/END");
    }
});
mplayer("content").setup({playlist: [{sources: [{file: 'http://dnswebsite.tld/appz?UserSign="I WANT MY auth VAR HERE"/playpath'}]}]});

Your problem is that your variable auth is stucked inside the scope of your success callback function. This should solve the problem:

var auth;
$.ajax({
    url: your_url,
    type: 'GET',
    success: function (res) {
        var text = res.responseText;
        auth = text.match("BEGIN(.*)/END");
    }
});
mplayer("content").setup({playlist: [{sources: [{file: 'http://dnswebsite.tld/appz?UserSign="' + auth + '"/playpath'}]}]});
Sign up to request clarification or add additional context in comments.

2 Comments

Hi thnx for replying to me i tried your code doesnt work here's the full code //Getting the generated Auth Key $.ajax({ url: your_url, type: 'GET', success: function(res) { var text = res.responseText; var auth = text.match("BEGIN(.*)/END"); } }); //this code will be ouputed for the user as html to play the media with JWplayer mplayer("content").setup({ playlist: [{ sources: [{ file: 'dnswebsite.tld/appz?UserSign="I WANT MY auth VAR HERE"/playpath', }] }], });
yeah now i uderstand you passed the variable to global i test it with alert to print the variable but it shows undefined...when is out of $.ajax function... so check the whole script in pastbin pastebin.com/vThxfXag thnx for helping me

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.