public JsonResult SearchLocationJson()
{
var location = (from r in odbe.ODB_LLg_Master
orderby r.Pcode descending
select new
{
StrLocation = (r.A + "," + r.B+ "," + "VIC"),
StrL = r.L1,
StrL1 = r.L2
}).ToList();
return Json(location, JsonRequestBehavior.AllowGet);
}
function getLocations()
{
$.getJSON("/MapSearch/SearchLocationJson", function (data)
{
alert('show');
for (var i = data.length - 1; i >= 0; i--)
{
keywords.push(data[i].StrLocation);
kLat.push(data[i].StrLat);
kLng.push(data[i].StrLng);
}
$("#suburbField").show();
$("#loadingLabel").hide();
});
}
You don't have to return the SelectList, as it used for Dropdown items. Rather simply return the list as json and use it.
Try the above and let me know if it works.
-KR