Estaba tratando de llamar al boolean desde mi controlador, lo cual es true , pero cuando lo llamo ahora en mi Javascript ajax , no puedo obtenerlo.
$.ajax({ url: "/Shop/Accessories", contentType: "application/html; charset=utf-8", type: 'GET', dataType: "html", success: (function (result) { if (result) { //If I do result == true : still not working $('#owl1').html(result) $('#owl1').owlCarousel({ loop: true, nav: false, dots: false, autoplay: false, margin: 10, responsive: { 0: { items: 2 }, 600: { items: 3 }, 1000: { items: 4 } } }) } else { $(".noItem1").html(result); } }), error: (function (xhr, status) { alert(status); }) }) Estoy usando un tipo de datos dataType: html para la return View cuando la base de datos no tiene data
using (SqlConnection con = new SqlConnection(constring)) { string command = "select item_image, item_name, item_price item_number, item_type, date_added from cooking_items"; con.Open(); using (SqlCommand cmd = new SqlCommand(command, con)) { cmd.CommandTimeout = 60; SqlDataReader Creader1; Creader1 = cmd.ExecuteReader(); if (Creader1.HasRows == true) { con.Close(); con.Open(); DataTable dt = new DataTable(); using (SqlDataAdapter da = new SqlDataAdapter(cmd)) { da.Fill(dt); } con.Close(); return View("Cooking", dt); } else { return View("Cooking"); //When there's no data, these is the one who should call my ajax. } } }