Skip to content Skip to sidebar Skip to footer

Javascript Objects Working In Html But Not Php

I'm working on a website that uses a textbox and does something with what the user submits. On my index page where I use no PHP (all HTML), Javascript tabs that I would like to use

Solution 1:

If the HTML is right and the javascript is right and is loaded then it makes no difference whether the HTML came from a static file or was generated with PHP. The browser still sees it as just HTML (the PHP is server-side so the browser never sees that) and it is in the browser that the javascript runs.

Which leaves us with the following possibilities:

  1. THe HTML generated via PHP is different in some way (I know you say it isn't, but double check)
  2. The javascript file is not being loaded the second time

THis is assuming you are loading a whole page generated with PHP - if you start adding bits ysing ajax requests then the situation changes as you tab code is set up in document ready and only sees the page as it is then.

Solution 2:

Simple answer.

Any ideas why this would work when using HTML only but not when put inside a PHP function?

They both are very different. While Javascript is client side coding, PHP is server-side coding.

You should really understand the difference between them. Also the syntax differs.

Post a Comment for "Javascript Objects Working In Html But Not Php"