i have an external javascript file called ‘app.js’ which i have linked to my base.html file.
app.js has a single function called pay. now, in my index.html file, i have a button tag which when clicked should execute the pay function in the external app.js. but this doesn’t work.
it only works if i write the js function directly inside the index.html.
but i do not want the javascript to be inside the index.html.pls how do i do this
Can you post both your template where you include the app.js file in addition to the content of the app.js file?
Also, can you verify from your console log or your browser log that the app.js file has been loaded?
Ken
this runs perfectly well . but when i take the function into the external js file. it does nothing. pls
ignore the verify.php
What do the console errors in the developers tool say? They often give a clue regarding JS.
When you are posting code, please do not post images. (it’s not readable by many people on different devices)
Post the text of your code between lines consisting of only three backtick - ` characters. That means you’ll have one line that only has ```, followed by your lines of code, followed by another line of ```. Make sure you use the backtick (`) and not the apostrophe (’).
So please post the content of your app.js file, the template you are rendering, and confirmation that the browser is successfully retrieving the app.js file from the server.
thanks your first suggestion worked. i checked the console, it wasn’t loading. found out i added the ile to the the wrong project. thank you again it was worth the days work