Difference between script src and code inside script in asp.net mvc 3 razor partial view executing jquery.ajax
asp.net mvc 3 with razor I have a script inside a partial view
&l开发者_JAVA百科t;script type="text/javascript">
function MYFunction()
{
...
</script>
It's working fine
If I move the code inside a .js file and try to load the script with
<script src="path to my script file" type="text/javascript"></script>
The script doesn't execute some code, a jquery.ajax, the rest of the code is executed (I'm debugging inside visual studio)
Any suggestion?
My guess is that you use the '@' symbol and some c# code inside the javascript function and it doesn't work inside js file only in cshtml - razor file.
Am I right?
Try following:
<script type="text/javascript" src="path to my script file">
Ensure your scripts are loading in the proper order. Meaning, if your script uses JQuery then you will have to have the tag loading JQuery BEFORE your script's tag.
精彩评论