JQuery------$.getJSON()方法的使用

html(../Home/Index.cshtml)

<body>
    <button class="Btn">按钮</button>
</body>

 

js

$(document).ready(function () {
    $(".Btn").click(function () {
        $.getJSON("../Home/Index",function (data) {
            for (var i = 0 ; i < data.length; i++) {
                var obj = data[i];
                alert(obj);
            }
        });
});

 

HomeController

public ActionResult Index(string url)
{
  ArrayList list = new ArrayList() {"1","2","3" };
  return Json(list,JsonRequestBehavior.AllowGet); ;
}

 

posted @ 2016-10-24 17:35  玉天恒  阅读(253)  评论(0编辑  收藏  举报