0

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?

2
  • seems like your pages is located in /GServices/Teficiancio, and it will look for the javascript file in /GServices/Teficiancio/Content/js/paraGrafico.js. Try after chaging the src inside script tag to ../../Content/js/paraGrafico.js Commented Aug 1, 2020 at 20:06
  • @AlwaysaLearner the result is the same. I supposed it is something relative to scope, but I cannot understand how to solve. If I locate the code directly to view Teficiencia the program run without problem. How I bundle is: bundles.Add(new ScriptBundle("~/bundles/highcharts").Include( "~/Content/js/highcharts.js", "~/Content/js/exporting.js")); bundles.Add(new ScriptBundle("~/bundles/paraGrafico").Include( "~/Content/js/paraGrafico.js")); if you see I use the same way for paraGrafico.js and for highchart.js. Commented Aug 1, 2020 at 20:44

1 Answer 1

1

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.

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

Comments

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.