I have this ajax call. This is the first time I'm experiencing this problem. First, the break point on my action is not being hit. Second, the success function is being executed. Third, the value of my storeList/data is the whole code of the whole body content. This might be caused of my action not being found.
$.ajax({
type: 'POST',
url: '/reports/GetStoreFranchiseList?franchiseId=' + franchiseId,
success: function (storeList) {
console.log(storeList);
var appendStr = "<li><a href='#' onclick=changeStore('All', 'All')>All</a></li>";
// $.each(storeList, function (k, v) {
// console.log(v);
// appendStr += "<li><a href='#' onclick=changeStore('" + v.Id + "','" + v.StoreName + "')>" + v.StoreName + "</a></li>";
// });
console.log(appendStr);
$(".rptStoreDdl").html(appendStr);
$("#rptStoreDdlDv").removeClass().addClass("btn-group");
}
});
When I try uncommenting the each function, I get this error: Uncaught TypeError: Cannot use 'in' operator to search for '21748' in #<error>
Obviously because the data is wrong. Any Ideas guys? Thanks!
EDIT:
Tried accessing it via fiddler and I'm getting this: /Error/NotFound?aspxerrorpath=/reports/GetStoreFranchiseList
This triggers my customer error for not found. I'm really not sure why my action is not found.
Controller action:
[InPrivate]
public class ReportsController : Controller
{
[HttpGet]
public JsonResult GetStoreFranchiseList(string franchiseId)
{
var data = new List<Store>();
if(WebUser.Franchisees != null && WebUser.Franchisees.Count() > 0)
{
data = WebUser.Franchisees.FirstOrDefault(a => a.Id == franchiseId).Stores;
}
return Json(data, JsonRequestBehavior.AllowGet);
}
}