简体   繁体   中英

Passing values from controller to view

Controller

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

View

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

But it seem to invoke dispose(); twice..the reason being the first time it calls return View(); and the second var windows = window.open('Admin/GenerateQRCode'); I need to pass data from controller to javascript in sencha and also pass them to the View..is this possible?

Try this:

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) {

    }

Please try this.. Sorry earlier one is not working...

$.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);
        }

This is work for me...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM