Here is my View
<script>
function filltable() {
alert("in other method");
window.oTable = $("#table").dataTable({
"bServerSide": true,
"sAjaxSource": "Url.Action(User/GetResult)",
"sAjaxDataProp": "aaData",
"aoColumns": [
{ "mDataProp": "USER_NAME" },
{ "mDataProp": "EMAIL_ID" },
{ "mDataProp": "MOBILE_NO" }
],
"bJQueryUI": true,
"bProcessing": false
});
}
</script>
Why sAjaxSource doesn't redirect to the url? Please help...
UPDATE
Now it is rediecting to Url.bt it doesnt show data which is coming from controller in this format in mvc2---->
{[
{
"USER_NAME": "alpa",
"MOBILE_NO": "000",
"EMAIL_ID": "alpa.sae",
"COLOR_NAME": "Red",
"COLOR_ID": 0
},
{
"USER_NAME": "alpas",
"MOBILE_NO": "000",
"EMAIL_ID": "alpa.sae",
"COLOR_NAME": "Green",
"COLOR_ID": 0
}
]}
My controller
[HttpGet]
public JsonResult GetResult()
{
JArray JsonArray = new JArray();
JObject jo = new JObject();
List plist = new List();
User tUser = new User();
tUser.USER_NAME = "alpa";
tUser.EMAIL_ID = "alpa.sae";
tUser.MOBILE_NO = "000";
tUser.COLOR_NAME = "Red";
plist.Add(tUser);
tUser = new User();
tUser.USER_NAME = "alpas";
tUser.EMAIL_ID = "alpa.sae";
tUser.MOBILE_NO = "000";
tUser.COLOR_NAME = "Green";
plist.Add(tUser);
JsonArray = (JArray)JToken.FromObject(plist);
jo["Message"] = "Data Saved Succeffully";
jo["data"] = JsonArray;
var aaData = new Response(true, "Contact Successfully Submitted", jo["data"].ToString());
return Json(aaData);
}
}