I want to return a random value from the bank and already display in another tab, through a function. For when I click on send already calls this function.
Controller
public ActionResult RetornarVideoAleatorio(int id)
{
var lista = db.Videos.Where(a => a.Id == id).FirstOrDefault();
return View(lista);
}
HTML
<section id="main"><form>
<input type="text" id="titulo" name="titulo" value="" required="" placeholder="Titulo" />
<input type="text" id="video-url" name="url" required="" value="" placeholder="url" />
<button id="submit" onclick="funcaoOnclick();">Enviar Video</button>
</form>
</section>
Javascript
function RetornarUrl(id) {
var url = "/Video/RetornarVideoAleatorio" + id;
$.ajax({
url: url
, type: "GET"
, data: { id: id }
, datatype: "Json"
, success: function (data) {
alert("retornou");
},
error: function () {
alert("Erro");
}
});
}
function funcaoOnclick() {
SalvarItens()
RetornarUrl(id);
}