javascript - call function from external js (php) file -


I have a file where I place all the scripts so that my pages are not messy (I have a php file that requires JavaScript Generates). I basically look like this:

  & lt; Html & gt; & Lt; Top & gt; & Lt; Script type = "text / javascript" src = "jquery.js" & gt; & Lt; / Script & gt; & Lt; Script type = "text / javascript" src = "script.php" & gt; & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Input type = "button" onClick = "return blah ();" / & Gt; & Lt; / Body & gt; & Lt; / Html & gt;  

script.php

  & lt ;? Php header ("content-type: application / x-javascript"); ? & Gt; Function blah () {alerts ("blah"); } $ (Document) .ready (function () {});  

jquery cover is $ (document) in script.php. The funny thing is that when I put all the jquery related stuff together, I got a "blah not defined" error when I put the function blah () inside this wrapper, but when I put it out - works perfectly So, what can be the problem?

Surely this is an easy problem?

  $ (function () {window.blah = function () {};});  

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -