I have the following code in js
function consultaSolicitacao() {
id = getVar("id");
serviceURL = "/Solicitacao/ConsultaSolicitacao";
$.get(serviceURL, null, function (data) {
var aux = data.length;
var tblText = '';
for (var i = 0; i < aux; i++) {
var tmpArgs = data[i].id + ",'" + data[i].assunto
+ "','" + data[i].mensagem + "','" + data[i].endereco + "','" + data[i].anexo + "'";
var id = data[i].id;
tblText += '<div id="Solicitacoes"><div>';
tblText += '<span id="idSolicitacao">' + data[i].id + '</span>';
tblText += '</div></div></a>';
}
document.getElementById("solicitacaoID").innerHTML = tblText;
});
}
I need to pass the value of my 'id' variable to the controller:
public ActionResult ConsultaSolicitacao(int id)
{
var x = Teste.ConultaSolicitacao(id);
return new JsonResult()
{
Data = x, JsonRequestBehavior = JsonRequestBehavior.AllowGet
};
}
But I do not know how to send the js variable to the controller. The controller is already waiting but I do not know how.