将值从控制器传递到视图

时间:2015-09-07 03:26:44

标签: javascript c# extjs

控制器

public ActionResult Booklist(string bookid) {
   return View();
}

查看

// other codes 
url: 'Index/Booklist',
method: 'POST',
success: function (a) {
   var windows = window.open('Index/Booklist');
}

但似乎两次调用dispose();。原因是它第一次调用return View();而第二次调用var windows = window.open('Admin/GenerateQRCode');     我需要将数据从控制器传递到sencha中的javascript,并将它们传递给View ..这可能吗?

1 个答案:

答案 0 :(得分:0)

试试这个:

public ActionResult Booklist([DataSourceRequest] DataSourceRequest request,string bookid) 
{
//result should be your data.
var result=0;
    return Json(result, JsonRequestBehavior.AllowGet);
}



 // other codes 
    url: 'Index/Booklist',
    method: 'POST',
    data:{
          'bookid': bookid
         },
    success: function (result) {

    }

请试试这个..对不起,早先一个不行......

$.ajax({
            url: "@Url.Action("Booklist", "Home")",
            data: {
                'bookid': bookid

            },
            dataType: 'json',
            async: true,
            type: 'POST',
            success: function (response) {

            }


        });

public ActionResult Booklist( string bookid)
        {
            var result=1;
            return Json(result, JsonRequestBehavior.AllowGet);
        }

这对我有用......