Guest User

Untitled

a guest
Jan 22nd, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. function getCountries()
  2. {
  3. // alert();
  4. var obj = {};
  5. obj.countryName = '';
  6. $.ajax({
  7. type: 'GET',
  8. url: '/Business/GetCountries',
  9. dataType: 'json',
  10. async: false,
  11. success: function (data) {
  12.  
  13. console.log(data);
  14.  
  15.  
  16.  
  17. },
  18. error: function (err) {
  19.  
  20. console.log(err);
  21. }
  22. });
  23.  
  24. }
  25.  
  26. namespace timeclock.controller
  27. {
  28. class BusinessController : System.Web.Mvc.Controller
  29. {
  30. [HttpGet]
  31. [Route("Countroller/GetCountries")]
  32. public JsonResult GetCountries(string countryName)
  33. {
  34. //List<countries_model> countrylist = null;
  35. var myresult = "{'name':'John', 'age':31, 'city':'New York' }";
  36. return Json(myresult,JsonRequestBehavior.AllowGet);
  37. }
  38. }
  39. }
  40.  
  41. public static void RegisterRoutes(RouteCollection routes)
  42. {
  43. routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
  44.  
  45. routes.MapRoute(
  46. name: "Default",
  47. url: "{controller}/{action}/{id}",
  48. defaults: new { controller = "Home", action = "signup", id = UrlParameter.Optional },
  49. namespaces: new[] { "timeclock.controller" }
  50. );
  51.  
  52. routes.MapMvcAttributeRoutes();
  53. }
Add Comment
Please, Sign In to add comment