I used the below method for doing Async
postback using AJAX
. This works fine on clicking submit
. But i would like to know, is that pos
The answer to your first question "is that possible to call various ActionMethods in a controller via AJAX"
is a big yes. You may call any action method from your controller through Ajax though the only result generated depends on various things like whether you send a view or partial view or JSON result.
for your next question :
I will be posting some codes
Controller.cs
public JsonResult getCity(string country)
{
var temp = (from cntry in db.Table3.OrderBy(s => s.country)
where (string.Compare(cntry.country, country) == 0)
select cntry.city).ToList();
return Json(temp, JsonRequestBehavior.AllowGet);
}
View
Countries
State
@*
The following jquery code finds the selected option from country dropdown
and then sends an ajax call to the Home/getcity method
and finally populate it to the city dropdown
*@
This will show a dropdown of countries list. Once a country is selected it will render a new dropdown of city list