0

I want to call a function from my master .js file - from within my php page. Is this possible?

<script type="text/javascript">
   functionName(); //calling function from master.js file
</script>

Doesn't seem to work.

4
  • 1
    Should work. Did you load master.js before this script? Commented Oct 25, 2011 at 18:43
  • you need to include master.js before the line you call the funcion inside master.js Commented Oct 25, 2011 at 18:44
  • Yep I checked, can't figure it out. Commented Oct 25, 2011 at 18:45
  • Try to type in master.js : "alert(1)" then check if the alertbox is shown ? Commented Oct 25, 2011 at 18:50

1 Answer 1

1

It should be as long as the external script is loaded first and "functionName()" is attached to the global scope

Sign up to request clarification or add additional context in comments.

6 Comments

It seems to call it when it's not within the dom ready handler
when the master.js is not in the dom ready handler? or when call in your questin is not in the dom ready handler
when the function i'm trying to call is outside the dom ready handler it seems to call the function, although when it's inside, it fails.
Right this makes sense since the call is not in the dom ready handler it will fire off first since getting the dom ready takes a little while. Try putting the function call in the dom ready handler as well
I can't I'm afraid I'm trying to pass a jQuery function through the main php file because I want to use the $_GET[]; query to trigger the function.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.