Hello, I need your help again, I need to make a VerDetails of the follow-up, I have done the selection and it returns the required fields. In the controller I have the DetailsTracking function In the part that I need your help is in javascript I have no idea how to do the function, I've already started it but I do not know where to throw it. I'm new to MVC and Razor and I still have not got the hang of it.
The html link - > js-> controller-> js-> html
The final result should be shown as a table in a popup
If you need the files, I have them at your disposal. Thanks in advance.
Here I leave you the function of the controller
[HttpGet]
public ActionResult DetallesTracking(string numeroguia)
{
var rootObject = new JObject()
{
new JProperty("tracking", JObject.Parse("{}"))
};
try
{
System.Text.StringBuilder stbSQL = new System.Text.StringBuilder();
stbSQL.AppendLine("SELECT convert(varchar(100),fhit,106) as Fecha, ");
stbSQL.AppendLine("hhit as Hora, ");
stbSQL.AppendLine("dtrk as Tracking, ");
stbSQL.AppendLine("hit.dhit as Descripcion ");
stbSQL.AppendLine("FROM aebtrk trk ");
stbSQL.AppendLine("INNER JOIN aebhit hit on trk.ihit = hit.ihit ");
stbSQL.AppendLine("INNER JOIN tdahaw tda on trk.creg = tda.itdahaw ");
stbSQL.AppendLine("INNER JOIN tdaprehaw prehaw on tda.itdahaw = prehaw.itdahaw");
stbSQL.AppendFormat("WHERE tda.ctdahaw like '{0}'", numeroguia).AppendLine();
stbSQL.AppendLine("ORDER BY Fecha ASC ");
CopaCursoEntities dbbf = new CopaCursoEntities();
DetallesTracking detallesTracking = dbbf.Database.SqlQuery<DetallesTracking>(stbSQL.ToString()).FirstOrDefault();
if (detallesTracking != null)
{
rootObject["tracking"] = JToken.FromObject(detallesTracking);
}
}
catch (Exception e)
{
var tokenError = JToken.FromObject(e);
rootObject["error"] = JToken.FromObject(e);
}
return new ContentResult
{
Content = rootObject.ToString(),
ContentType = "application/json"
};
}
here the function of JS :
VerDetalles = function () {
var url = $("#UrlDetallesTracking").val();
var numeroguia = $("#txtTracking").val();
if (numeroguia == '') {
return;
}
showLoader(Resources.consultando_tracking);
var data = { numeroguia: numeroguia }
$.get(url, data, function (result) {
if (underscore.has(result, "error")) {
mostrarMensajeKo(Resources.intente_mas_tarde, 3000);
}
else {
}
}
);
}
and here the HTML section where the button that makes the call to the js function is.
<div class="col-3"><input type="button" class="btn btn-primary btn-sm w-100" id="detallestracking" value="Ver detalles" onclick="VerDetalles();"/></div>