Reputation: 1328
I have the j-query function test()
in (chart.js) another solution file which is added the reference of main projects. Now i want to call the test()
method from default.aspx page.
This is my code.
function test(){
//for Example
}
<script>
test(); //call chart.js function
</script>
If i call the test method() from default.aspx page it is "undfined". how to call the j-query method which is located in another solution file but the same is added reference to the main project. Anyone could help on this..
Thanks,
Bharathi
Upvotes: 1
Views: 499
Reputation: 424
You have to add that js file (chart.js) before your script block, may be in head tags of page. like following
<script type="text/javascript" src="chart.js" />
and Make sure your jQuery file is added even before it. so it should be like following
<script type="text/javascript" src="jQuery.js" />
<script type="text/javascript" src="chart.js" />
<script type="text/javascript">
test(); //call chart.js function
</script>
Upvotes: 0
Reputation: 3610
In the head section of your aspx page add this:
<script type="text/javascript" src="chart.js" />//add reference of the chart.js file
<script type="text/javascript" language="javascript">
test(); //call chart.js function
</script>
Upvotes: 0
Reputation: 27041
It seems like you are using a JS.page and that you are trying to call it with a script.
If you want to have your chart.js called into the default.aspx page do it like this.
<script src="assets/chart.js"></script>
place this in the head sections
Upvotes: 0
Reputation: 5947
Try this
<script type="text/javascript" src="chart.js">
$(document).ready(function()
{
test();
});
</script>
Upvotes: 1
Reputation: 11731
you should put reference to tht perticular js file at starting of the page like below :-
<script type="text/javascript" src="chart.js" />
<script>
test(); //call chart.js function
</script>
Upvotes: 1