Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public JsonResult GetData(string param1, string param2)
- {
- List<YourModecClass> data = new List<YourlModelClass>();
- //Mockup data only...you should get the data from DB source
- data = new List<YourModelClass>();
- data.Add(new YourModelClass() { Region = "", Value_TY = 0});
- data.Add(new YourModelClass() { Region = "", Value_TY = 0 });
- return Json(data, JsonRequestBehavior.AllowGet);
- }
- function getServerData() {
- var entity = {
- param1: param1 //--> ths is a variable
- param2: "value" //--> hardcoded
- }
- var parameter = JSON.stringify(entity);
- $.ajax({
- type: "POST",
- url: url + "/GetData",
- data: parameter,
- dataType: "json",
- contentType: "application/json",
- async: true,
- beforeSend: function () {
- },
- success: function (response, status, xhr) {
- yourJavascriptVariable = response;
- doSomethingWithreceivedDataAbove();
- },
- error: function (xhr, status, error) {
- debugger;
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement