JavaScript stops working after enabling embedded PHP in Apache

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bernhard Georg Enders

    JavaScript stops working after enabling embedded PHP in Apache

    After issuing the command (apache httpd.conf file)
    AddType application/x-httpd-php .php .htm .html
    any attempt to include javascript code
    <script src="file.js" type="text/javascript"></script>
    into htm (or html) file fails. How can I successfully config Apache2 to
    work with
    embedded PHP and javascript at same time?

    TIA,

    Bernhard Enders.
    --
    Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
  • Davide Bianchi

    #2
    Re: JavaScript stops working after enabling embedded PHP in Apache

    On 2004-10-22, Bernhard Georg Enders <bgeneto@hotmai l.com> wrote:[color=blue]
    > work with embedded PHP and javascript at same time?[/color]

    Use a php #include to load the js file.
    Davide

    --
    If Bill Gates had a nickel for every time Windows crashed... Oh wait, he
    does!

    -- From a Slashdot.org post

    Comment

    • Grant Wagner

      #3
      Re: JavaScript stops working after enabling embedded PHP in Apache

      Bernhard Georg Enders wrote:
      [color=blue]
      > After issuing the command (apache httpd.conf file)
      > AddType application/x-httpd-php .php .htm .html
      > any attempt to include javascript code
      > <script src="file.js" type="text/javascript"></script>
      > into htm (or html) file fails. How can I successfully config Apache2 to
      > work with
      > embedded PHP and javascript at same time?[/color]

      You shouldn't be having a problem, you aren't modifying either the mime
      type (text/javascript) nor the extension (.js) with that directive.

      I would suggest you do 3 things:

      1) search httpd.conf for other instances of ".js".
      2) check mime.types for other instances of "text/javascript" or ".js", the
      only one you might have is "applicatio n/x-javascript js" and that
      should not affect your ability to send script as <script
      type="text/javascript">
      3) ensure your JavaScript loads correctly _without_ PHP, and after you've
      enabled PHP, ensure that the HTML source you are viewing is what you
      _think_ you're sending. For example, if you had PHP that looked like: echo
      "script type=\"text/javascript\" src=\"" . someVariable . "></script>"; Do
      you notice the closing quote on the SRC attribute is missing? You would if
      you loaded that page into your browser and did a View -> Source.

      But quite frankly, most browsers aren't that picky. For example, our
      corporate Web server sends .js files as application/x-javascript, and I've
      never had a problem with <script type="text/javascript">. I would suspect
      your problem is more with some change you made to the .js file, or some
      interaction between quotation marks delimiting PHP text and internal
      quotation marks within the generated HTML. That's why it's important to
      View -> Source.

      --
      Grant Wagner <gwagner@agrico reunited.com>
      comp.lang.javas cript FAQ - http://jibbering.com/faq

      Comment

      Working...