• Invoke action which type of result is JsonResult on controller from view using Ajax or geJSon


     $.getJSON("/StoragePoint/ReadStoragePoint/", { id: $("#StoragePoint_Id").val() }, function (data) {
                            $("textarea[id='StoragePoint_AdditionalDetails']").val(data.AdditionalDetails);
                        }).success(function () { alert("second success"); })
                       .error(function () { alert("error"); })
                       .complete(function () { alert("complete"); });

    Or

     $.ajax({
                            type: 'POST',
                            url: '/StoragePoint/ReadStoragePoint',
                            data: { 'id': $("#StoragePoint_Id").val() },
                            dataType: 'json',
                            success: function (jsonData) { alert("Yes"); },
                            error: function () { alert('Error'); }
                        });

      [Authorise(PermissionIdentifier.ReadStoragePoint)]
            [AcceptVerbs(HttpVerbs.Get)]
            public JsonResult ReadStoragePoint(int id)
            {
                string additionalDetails = StoragePointRepository.ReadSingle(id).AdditionalDetails;
                var result = new JsonResult()
                {
                    JsonRequestBehavior = JsonRequestBehavior.AllowGet,
                    Data = new
                              {
                                  AdditionalDetails = additionalDetails
                              },
                };
                return result;
            }

    JSon method:

  • 相关阅读:
    当别人没说好,那么事就没达成协定
    设计模式(六):原型模式
    《一拳超人》观后感
    设计模式(五):中介者模式
    设计模式(四):单例模式与工厂模式
    设计模式(二):构造器模式与模块模式
    设计模式(一):概念小谈
    CSS代码记录
    java之如何实现调用启动一个可执行文件,exe
    file类之目录
  • 原文地址:https://www.cnblogs.com/Mac_Hui/p/2615309.html
Copyright © 2020-2023  润新知