0
I’m switching to a Partial View via a two-parameter controller, music and artist. Already in PV I pass to the function fetchLetra() that is in the file letraAPI.js these parameters for the return of Function, however, this is not happening because apparently Partial is not loading any script, it is this way
@model letra.Infra.Models.Letra
@{
var artista = Model.Artista.ToString();
var musica = Model.Musica.ToString();
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script type="text/javascript" src="@Url.Content("~/js/letraAPI.js")"></script>
<script type="text/javascript">
fetchLetra(artista, musica);
alert("OK");
</script>
Loading the page the HTML looks like this
<div id="letraAPI" class="panel-content">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script type="text/javascript" src="/js/vagalumeAPI.js"></script>
<script type="text/javascript">
fetchLetra(artista, musica);
alert("OK");
</script>
</div>
nothing happens, not even Alert runs.
fetchLetra
is what? A function in the fileletraAPI.js
?– Jéf Bueno
Exactly jbueno!
– Gabriel Bernardone
This is to be executed as soon as the screen is loaded? Did not miss to put it inside
$(document).ready(function () { });
?– Jéf Bueno
No, this is running after a click action, which calls the controller and the controller passes the required parameters to Partial
– Gabriel Bernardone
Perai, you put JS code inside the partial?
– Jéf Bueno
The references are in Partial because they are in main and still not working, so I thought I had to put in both places. One detail is that by placing this function directly in the main referencing the file letraAPI.js, it works normally.
– Gabriel Bernardone