2011-09-22 75 views

回答

4

當您調用控制器時,您可以將其作爲參數傳遞。例如,如果您正在調用使用AJAX控制器動作:

$.post('/someaction', { someValue: someVariable }, function() { 
    ... 
}); 
1
[HttpPost] 
public ActionResult someAction(string id) 
{ 
return Content("got it"); 
} 

腳本

$(function(){ 

var someid='12'; 
$.post('/Controller/someAction',{id:someid},function(data){ 
//this call back is executed upon successfull POST 
console.log(data); // got it" 

}); 
}); 
1

您可以在形式與您的字符串變量的值,增值的使用隱藏的輸入字段。當您發佈表單時,您可以照常讀取值。

相關問題