2

For my application I need to pass a parameter through zend to my exter javascript file. I need the server url in the javascript with the language parameter.

my javascript is placed in /js/javascript.js

I've tried the follow

layout.phtml

$this->headScript()
    ->prependScript('BASE_URL = "test";')
    ->appendFile('/js/javascript.js');

javascript.js

var url = BASE_URL

But my firebug console keeps saying that BASE_URL is not defined. What is the good way to do this?

Regards.

Nicky

1 Answer 1

2

First you include javascript.js, and just after it you prepend script before appended javascript.js.

$this->headScript()
     ->appendFile('/js/javascript.js')
     ->prependScript('BASE_URL = "test";');
Sign up to request clarification or add additional context in comments.

Comments

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.