hai all,while i m calling ajax calls i not able to call methos in my controller here is my code
@{
UsersDAL obj = new UsersDAL();
List CompanyName = new List();
DataTable dtCompanyDetails = obj.ShowCompany();
foreach (DataRow row in dtCompanyDetails.Rows)
{
CompanyName.Add(new SelectListItem { Value = row["CompanyId"].ToString(), Text = row["CompanyName"].ToString() });
}
}
function ShowCompany($this)
{
var CompanyName = $("#Company_Name").val();
alert("hello");
$.ajax({
URL: '/Admin/ShowCompany',
type:"GET",
datatype:"JSON",
data: { CompanyId: CompanyName },
success:function(s){
document.getElementById("table").innerHTML='
';
'+s[0]+'
'+s[1]+'
'+s[2]+'
'+s[3]+'
alert("hello");
}
});
alert("Welcome");
}
@using (Html.BeginForm())
{
@Html.ValidationSummary(true)
Select Company
@Html.DropDownListFor(Model => Model.CompanyName,CompanyName ,"Select", new {@id="Company_Name",@onchange="ShowCompany(this)" })
}
and in my controller
public ActionResult ViewCompanyProfile()
{
return View();
}
[HttpPost]
public ActionResult ShowCompany(int CompanyId)---------This one is not calling
{
DataTable dt = _objDAL.GetShowCompany(CompanyId);
int rowcount = dt.Columns.Count;
string[] strarray=new string[rowcount];
for (int i = 0; i < rowcount; i++)
{
strarray[i] = dt.Rows[0][i].ToString();
}
return Json(strarray,JsonRequestBehavior.AllowGet);
}
}
any suggestions are highly appreaciated
TIA
4 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Pawan VaishPosted May 30, 2016, 6:49 PM
aditya immadiPosted May 30, 2016, 3:37 AM
Ravi PatelPosted May 30, 2016, 3:37 AM
'+s[0]+'
'+s[1]+'
'+s[2]+'
'+s[3]+'
Ravi PatelPosted May 30, 2016, 3:26 AM
'+s[0]+'
'+s[1]+'
'+s[2]+'
'+s[3]+'