Jump to content

Ways of including JS files in PHP - NOT 'include'/'require_once'/'<script>' tags


sparklechic007

Recommended Posts

:shrug:

Hi, I'm wondering if anyone can tell me if there's a work around for calling js files in php.  Basically, I have an autosuggest field which is calling from a database.  However, when I try to use the js by using 'require_once' in php if I click on one of the entries on the autosuggest list it won't fill the textfield.  If I include the .js file in <html> at the top of the page I get 'headers already sent (by my configuration file linking to the database).'

 

I've also tried to include the <script> in the php instead using single quotes but this doesn't work. 

 

I can't change my configuration file as it's used by other pages, and I can't really put the form into a separate html file because it uses other code as well for when the actual submit button is sent (this is separate from the autosuggest). 

 

All I'm wondering is if there's another way to call the javascript in the PHP

 

in MOST php applications (excluding COMET or PUSH implementations) after the php has finished being executed, php exits.. meaning you cannot continue to modify the output the user sees already..

 

php is for the most part server side, with another select few exceptions, but for most WEB APPLICATIONS it is 98% server side, with like I said before, COMET and PUSH applications..

 

JavaScript, however, is a CLIENT SIDE language with another few exceptions.. but for the most part this is the language you will want to utilize to manipulate information already sent to the client (the browser).

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.