Rajeshwar
Rajeshwar

Reputation: 11651

Jquery + asp.net not being detected in one of the pages

I currently have this format in all of my pages. However in one of my pages a script file is not detecting jquery. I have something like this in the end of my main cshtml page

@section stylesheets {
   ....
}

@section scripts {
    <script type="text/javascript" src="~/Scripts/jquery-3.4.1.js"></script>
    <script type="text/javascript" src="~/Scripts/Panel.js"></script>
}

<script type="text/javascript" src="~/Scripts/jquery-3.4.1.js"></script>
<script type="text/javascript">
$(document).ready(function () {
    //do something
});
</script>

Now my Panel.js has a function whose jquery statement keeps failing with the message Panel.js:601 Uncaught TypeError: $(...) is not a function

This is in Panel.js
function showResponse()
{
    var result= $('#actionSelect option:selected')();
    
}

Any suggestions on what might be happening here ? I have tried numerous things but I am still not sure why this is happening ? Jquery works fine on scripts of other pages. It also does not complain on $(document).ready

Upvotes: 0

Views: 39

Answers (1)

Rajeshwar
Rajeshwar

Reputation: 11651

This was invalid var result= $('#actionSelect option:selected')(); it should have been var result= $('#actionSelect option:selected').text();

Upvotes: 1

Related Questions