Code Monkey home page Code Monkey logo

Comments (5)

tealborder avatar tealborder commented on July 26, 2024 1

Recheck how you're referring to the js file from the template. Looks like the path is incorrect in
<script type="text/javascript" src="dist/learning.js"></script>

from php-view.

ivanhdzd avatar ivanhdzd commented on July 26, 2024

Thanks for your response, how can I refer Javascript files?
With NodeJS and ExrepssJS (I usually work with this technologies) it works.
Regards.

from php-view.

kAlvaro avatar kAlvaro commented on July 26, 2024

Please use the browser's console to inspect the exact contents of the dist/file.js that's being sent. I suspect it's HTML rather than the file contents.

If you are using PHP builtin server, I believe you need to return false inside public/index.php when the request belongs to a static file, as in this example:

if (PHP_SAPI == 'cli-server') {
    $url  = parse_url($_SERVER['REQUEST_URI']);
    $file = __DIR__ . $url['path'];

    // check the file types, only serve standard files
    if (preg_match('/\.(?:png|js|jpg|jpeg|gif|css)$/', $file)) {
        // does the file exist? If so, return it
        if (is_file($file))
            return false;

        // file does not exist. return a 404
        header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found');
        printf('"%s" does not exist', $_SERVER['REQUEST_URI']);
        return false;
    }
}

This is typically not an issue with any other server because you configure it to only call index.php when the request doesn't ask for an existing file.

from php-view.

piotr-cz avatar piotr-cz commented on July 26, 2024

Make sure that <base href="" /> is pointing to the base url of the application.

See MDN

from php-view.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.