0

On my index.html I am doing the following:

<script  src="jquery/jquery.js"></script> 
<script  src="managment.js"></script>
<script  src="jquery/jquery.mobile-1.1.0.js"></script> 

After doing some calculation, I have the need of using a function from the managment.js file:

 $.getScript("managment.js", function(){

                            alert("Script loaded and executed.");
                            login();
                            });
            }

And finally the managment.js file:

<script type="text/javascript">
function login(){
    alert("asdasdasdasdasdasd");
}
</script>

My issue, is that the login() function is never called. Actually the alert I have inside getScriptfunction is not called either, but the strange thing is that if I check if the jquery.js file is loaded the alert is called. More, if I try to call login() without doing getScriptnothing happens has expected. My files structure is the following:

enter image description here

(note: you can see that I am using 2 managment.js files. I tried both approaches to see if the problem was with the path of the file.)

What am I missing here? For relevance, I am using PhoneGap, but this isn't working on the browser as well.

0

1 Answer 1

1

The management.js file should not contain the <script type="text/javascript"> tag. It should be:

function login(){
    alert("asdasdasdasdasdasd");
}

Hope it helps! :)

Sign up to request clarification or add additional context in comments.

2 Comments

Yes it was that. As you can see from this "kind of problem" I don't have much experience in Java Script. Could you explain me why it doesn't need the <script type="text/javascript">?
@JackyBoy, .js file is written purely for JavaScripts. And the same way, .css for pure CSSs. So, they don't need the <script> or <style> tags. And moreover, these tags belong to HTML and not JavaScript or CSS. They say that the enclosed stuff is not HTML and they are either JavaScript or CSS. You get it?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.