Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2014
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. public JsonResult GetData(string param1, string param2)
  2. {
  3. List<YourModecClass> data = new List<YourlModelClass>();
  4.  
  5. //Mockup data only...you should get the data from DB source
  6. data = new List<YourModelClass>();
  7. data.Add(new YourModelClass() { Region = "", Value_TY = 0});
  8. data.Add(new YourModelClass() { Region = "", Value_TY = 0 });
  9. return Json(data, JsonRequestBehavior.AllowGet);
  10. }
  11.  
  12. function getServerData() {
  13. var entity = {
  14. param1: param1 //--> ths is a variable
  15. param2: "value" //--> hardcoded
  16. }
  17. var parameter = JSON.stringify(entity);
  18.  
  19. $.ajax({
  20. type: "POST",
  21. url: url + "/GetData",
  22. data: parameter,
  23. dataType: "json",
  24. contentType: "application/json",
  25. async: true,
  26. beforeSend: function () {
  27. },
  28. success: function (response, status, xhr) {
  29. yourJavascriptVariable = response;
  30. doSomethingWithreceivedDataAbove();
  31. },
  32. error: function (xhr, status, error) {
  33. debugger;
  34. }
  35. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement