ajax with asp.net mvc3


/ Published in: C#
Save to your folder(s)

accessing getdev action of home controller which returns jsonresult


Copy this code and paste it in your HTML
  1. $.ajax({
  2. type: "GET",
  3. url: "/home/getdev",
  4. data: "{}",
  5. contentType: "application/json; charset=utf-8",
  6. dataType: "json",
  7. success: function(msg) {
  8. // Do something interesting here.
  9. console.log(msg);
  10. }
  11. });//ajax ends here
  12.  
  13.  
  14.  
  15. public JsonResult GetDev()
  16. {
  17. return Json(new {author = "najam sikander awan", email="[email protected]"},JsonRequestBehavior.AllowGet);
  18. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.