Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.52 KB | None | 0 0
  1. jquery.min.js:2 Uncaught TypeError: Cannot use 'in' operator to search for 'length' in error
  2. at d (jquery.min.js:2)
  3. at Function.each (jquery.min.js:2)
  4. at Object.success (MostrarMascotas:485)
  5. at c (jquery.min.js:2)
  6. at Object.fireWith [as resolveWith] (jquery.min.js:2)
  7. at l (jquery.min.js:2)
  8. at XMLHttpRequest.<anonymous> (jquery.min.js:2)
  9.  
  10. d @ jquery.min.js:2
  11. each @ jquery.min.js:2
  12. success @ MostrarMascotas:485
  13. c @ jquery.min.js:2
  14. fireWith @ jquery.min.js:2
  15. l @ jquery.min.js:2
  16. (anonymous) @ jquery.min.js:2
  17.  
  18. $.ajax({
  19. type: "POST",
  20. url: '@Url.Action("BusquedaInstantanea", "Pruebas")',
  21. data: JSON.stringify(array_mascotas),
  22. dataType: "json",
  23. contentType: "application/json; charset=utf-8",
  24. success: function (rpta) {
  25.  
  26. $(".tr-mascota").remove();
  27.  
  28. $.each(rpta, function (index, element) {
  29.  
  30. var registro =
  31.  
  32. '<tr class="tr-mascota">'+
  33. '<td class="id_mascota">'+
  34. element.id_mascota+
  35. '</td>'+
  36. '<td class="dni_mascota">'+
  37. element.dni_mascota+
  38. '</td>'+
  39. '<td class="nombre_mascota">'+
  40. element.nombre_mascota+
  41. '</td>'+
  42. '<td class="ape_pat_mascota">'+
  43. element.ape_pat_mascota+
  44. '</td>'+
  45. '<td class="ape_mat_mascota">'+
  46. element.ape_mat_mascota+
  47. '</td>'+
  48. '<td>'+
  49. '@Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ })' + '|' +
  50. '@Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ })' + '|' +
  51. '@Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ })' +
  52. '</td>'+
  53. '</tr>';
  54.  
  55. $("tbody").append(registro);
  56. });
  57.  
  58. },
  59. error: function (req, textStatus, errorThrown) {
  60. alert('Ooops, something happened: ' + textStatus + ' ' + errorThrown);
  61. }
  62. });
  63.  
  64. [HttpPost]
  65. public JsonResult BusquedaInstantanea(string data)
  66. {
  67. List<ClsMascota> temporal = new List<ClsMascota>();
  68.  
  69. try
  70. {
  71. SqlCommand cmd = new SqlCommand("USP_SEARCH_LIVE", con);
  72. cmd.CommandType = CommandType.StoredProcedure;
  73. cmd.Parameters.AddWithValue("@data", data);
  74. con.Open();
  75.  
  76. SqlDataReader read = cmd.ExecuteReader();
  77. while (read.Read())
  78. {
  79. ClsMascota mascota = new ClsMascota()
  80. {
  81. id_mascota = read.GetInt32(0).ToString(),
  82. dni_mascota = read.GetString(1),
  83. nombre_mascota = read.GetString(2),
  84. ape_pat_mascota = read.GetString(3),
  85. ape_mat_mascota = read.GetString(4)
  86. };
  87.  
  88. temporal.Add(mascota);
  89. }
  90. read.Close();
  91. }
  92. catch
  93. {
  94. return Json("error");
  95. }
  96. finally
  97. {
  98.  
  99. con.Close();
  100. }
  101.  
  102. return Json(temporal);
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement