Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- jquery.min.js:2 Uncaught TypeError: Cannot use 'in' operator to search for 'length' in error
- at d (jquery.min.js:2)
- at Function.each (jquery.min.js:2)
- at Object.success (MostrarMascotas:485)
- at c (jquery.min.js:2)
- at Object.fireWith [as resolveWith] (jquery.min.js:2)
- at l (jquery.min.js:2)
- at XMLHttpRequest.<anonymous> (jquery.min.js:2)
- d @ jquery.min.js:2
- each @ jquery.min.js:2
- success @ MostrarMascotas:485
- c @ jquery.min.js:2
- fireWith @ jquery.min.js:2
- l @ jquery.min.js:2
- (anonymous) @ jquery.min.js:2
- $.ajax({
- type: "POST",
- url: '@Url.Action("BusquedaInstantanea", "Pruebas")',
- data: JSON.stringify(array_mascotas),
- dataType: "json",
- contentType: "application/json; charset=utf-8",
- success: function (rpta) {
- $(".tr-mascota").remove();
- $.each(rpta, function (index, element) {
- var registro =
- '<tr class="tr-mascota">'+
- '<td class="id_mascota">'+
- element.id_mascota+
- '</td>'+
- '<td class="dni_mascota">'+
- element.dni_mascota+
- '</td>'+
- '<td class="nombre_mascota">'+
- element.nombre_mascota+
- '</td>'+
- '<td class="ape_pat_mascota">'+
- element.ape_pat_mascota+
- '</td>'+
- '<td class="ape_mat_mascota">'+
- element.ape_mat_mascota+
- '</td>'+
- '<td>'+
- '@Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ })' + '|' +
- '@Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ })' + '|' +
- '@Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ })' +
- '</td>'+
- '</tr>';
- $("tbody").append(registro);
- });
- },
- error: function (req, textStatus, errorThrown) {
- alert('Ooops, something happened: ' + textStatus + ' ' + errorThrown);
- }
- });
- [HttpPost]
- public JsonResult BusquedaInstantanea(string data)
- {
- List<ClsMascota> temporal = new List<ClsMascota>();
- try
- {
- SqlCommand cmd = new SqlCommand("USP_SEARCH_LIVE", con);
- cmd.CommandType = CommandType.StoredProcedure;
- cmd.Parameters.AddWithValue("@data", data);
- con.Open();
- SqlDataReader read = cmd.ExecuteReader();
- while (read.Read())
- {
- ClsMascota mascota = new ClsMascota()
- {
- id_mascota = read.GetInt32(0).ToString(),
- dni_mascota = read.GetString(1),
- nombre_mascota = read.GetString(2),
- ape_pat_mascota = read.GetString(3),
- ape_mat_mascota = read.GetString(4)
- };
- temporal.Add(mascota);
- }
- read.Close();
- }
- catch
- {
- return Json("error");
- }
- finally
- {
- con.Close();
- }
- return Json(temporal);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement