Byron2017
Byron2017

Reputation: 1003

ASP.net cannot find javascript function

Maybe someone can help me to understand what is the problem, I have been spending hours into google for a solution.

I am using: ASP.NET entity framework

I have a view with this code:

<button type="button" id="btnGraficoNew">GeneraGrafico</button>
<div id="msgError"></div>
<div id="contenedorGrafico"></div>

@section scripts{
    @Scripts.Render("~/bundles/highcharts")
    @Scripts.Render("~/bundles/paraGrafico")

    <script type="text/javascript">
        $(document).ready(function () {
            $('.date-picker').datepicker({
                autoclose: true,
                todayHighlight: true
            }).next().on(ace.click_event, function () {
                $(this).prev().focus();
            });
            $("#btnGraficoNew").click("click", function () {
                alert("dentro de a");
                AlertaMensaje("hola mundo");
                ListaPubli(1, 1, 1);
            });
        });
    </script>
}

When I run the program the browser alert me with: "Uncaught ReferenceError: AlertaMensaje is not defined" but If I check into the page code the call exist.

pageGrafico.js source code access

Into google dev tools this is what I can see

google dev tools

  1. reference to paraGrafico.js file.
  2. cannot find a function that is inside of paraGrafico.js
  3. javascript file doesn't appear into content.

Any idea?

Upvotes: 0

Views: 665

Answers (1)

Byron2017
Byron2017

Reputation: 1003

The problem was that inside "paraGrafico.js" there was a javascript code error.

url: "@Url.Action("method", "controller")",

change to

url: '@Url.Action("method", "controller")',

After to solve it the browser call the function without problem.

Upvotes: 1

Related Questions