Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

163
Vistas
Why i cannot use $.ajax

I have one problem on my project. I would like access my function when iframe is over, but i try search how i can do this, but all solutions not worked, i dont know why? My project have templates of Asp.Net Web Application (.NET Framework).

Script js, when create a iframe and "try" connect to my function on WebForm1.aspx.cs:

<script>
    const tag = document.createElement("script");
    tag.id = "iframe-demo";
    tag.src = "https://www.youtube.com/iframe_api";
    const [firstScriptTag] = document.getElementsByTagName("script");
    firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
    let player;

    window.onYouTubeIframeAPIReady = () => {
        player = new window.YT.Player("player", {
            width: 500,
            height: 500,
            videoId: "M7lc1UVf-VE",
            events: {
                onStateChange: window.onPlayerStateChange
            }
        });
    };

    window.onPlayerStateChange = (event) => {
        if (event.data === 0) {
            jQuery.ajax({/* * */
                method: "POST",
                url: "/WebForm1.aspx/returnid",
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    console.log(textStatus);
                },
                success: function (result) {
                    console.log("success");
                }
            });
        }
    };
</script>

Code of WebForm1.aspx.cs:

[WebMethod]//[WebMethod()]
    public static string returnid(string subject, string message, string messageId, string pupilId)
    {
        Console.WriteLine("testar");

        return "";//https://www.youtube.com/watch?v=8elyZ6aGgZY
    }

I try use $.ajax, ajax, $Jquery there * and dont work. 1

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You have to import jQuery, add this inside the header tag:

<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda