I have a function calling a controller method in MVC3.
$.getJSON('@Url.Action("LoadCitiesByProvince", "Property")', { id: 1}, function (msg) {
alert("Data Saved: " + msg);
});
The final rendered Javascript:
$.getJSON('/MySite/Property/LoadCitiesByProvince', { id: 1 }, function (msg) {
alert("Data Saved: " + msg);
});
Firebug reports the following error:
s is undefined
[Break On This Error]
callbackContext = s.context || s,
When I debug my controller method is never hit. I have triple checked the controller method even calling it manually via the url in my browser (in whitch case it works as expected). This is my controller method:
[AcceptVerbs(HttpVerbs.Get)]
public JsonResult LoadCitiesByProvince(string id)
{
var modelList = this.GetCities(Convert.ToInt32(id));
var modelData = modelList.Select(m => new SelectListItem()
{
Text = m.Description,
Value = m.Id.ToString(),
});
return Json(modelData, JsonRequestBehavior.AllowGet);
}
At this point all I want to see is my controller method being hit and data coming back.