Reputation: 1805
I am working on creating widget using PHP and Javascript. In a widget, you get a small code like this:
<div id="wd_id"></div><script type="text/javascript" src="http://localhost/hasanResearch/php/widgets/widget.js"></script><script type="text/javascript">init_widget()</script>
You need to paste this code in your html file. This piece of code calls a function init_widget() in widget.js. The script inside widget.js
is somethis like this:
function init_widget(params){
document.getElementById("wd_id").innerHTML='html code goes here';
}
This will load the entire html page. In my case, the JS file and all the files are located on server. I have copied the code in my local. When I open the html file in browser, it shows error as Uncaught ReferenceError: init_widget is not defined
.
Do anyone have clue, why it is happening?
Upvotes: 0
Views: 931
Reputation: 3107
<script type="text/javascript" src="http://localhost/hasanResearch/php/widgets/widget.js"></script>
Instead of refering actual url src="http://localhost/hasanResearch/php/widgets/widget.js"
Refere with your base url
Like src= "/hasanResearch/php/widgets/widget.js"
Upvotes: 1