Advertisement
Guest User

Untitled

a guest
Aug 28th, 2015
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. function FillCity() {
  2. var stateID = $("#ddlState").val();
  3.  
  4. $.ajax({
  5. url: '@Url.Action("Employee", "Index")',
  6. type: "GET",
  7. dataType: "json",
  8. data: { state: stateID },
  9. async: true,
  10. processData: true,
  11. success: function (data) {
  12. alert("SSSS");
  13. },
  14. error: function (data) {
  15. alert("error");
  16. }
  17. });
  18. }
  19.  
  20. public ActionResult FillCity(int state)
  21. {
  22. var cities = subbuObject.Cities.Where(c=>c.StateID == state);
  23. return Json(cities, JsonRequestBehavior.AllowGet);
  24. }
  25.  
  26. $.ajax({
  27. url: '@Url.Action("YourActionNamne", "YourControllerName")',
  28. type: "GET",
  29. dataType: "json",
  30. data: { state: stateID },
  31. async: true,
  32. processData: true,
  33. success: function (data) {
  34. alert("SSSS");
  35. },
  36. error: function (data) {
  37. alert("error");
  38. }
  39. });
  40.  
  41. url: '@Url.Action("FillCity", "Employee")'
  42.  
  43. url: '@Url.Action("ActionName", "ControllerName", new { Area = "AreaName" })',
  44.  
  45. public class EmployeeController: Controller
  46. {
  47. [HttpGet]
  48. public ActionResult FillCity(int state)
  49. {
  50. var cities = subbuObject.Cities.Where(c=>c.StateID == state);
  51. return Json(cities , "application/json", JsonRequestBehavior.AllowGet);
  52. }
  53. }
  54.  
  55. <script>
  56. function fillCity() {
  57. var stateID = $("#ddlState").val();
  58.  
  59. $.ajax({
  60. url: '@Url.Action("FillCity", "Employee")',
  61. type: "GET",
  62. dataType: "json",
  63. data: { state: stateID },
  64. success: function (data) {
  65. alert("SSSS");
  66. },
  67. error: function (data) {
  68. alert("error");
  69. }
  70. });
  71. }
  72. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement