Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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/widet.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?

share
1  
should http://localhost/hasanResearch/php/widgets/widet.js be http://localhost/hasanResearch/php/widgets/widget.js – Orangepill 1 min ago

1 Answer

your script tag is calling "widet.js" not "widget.js".

share

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.