我在ASP.NET MVC3网站上的视图中有以下ajax函数.此功能从页面顶部的列表中调用,效果很好.但我需要来自查询字符串的另一个值,需要传递给控制器函数.我如何实现这一目标?
jQuery函数
function ShowDeals(itemNo) {
//get the vendor
var dialogDIV = $('<div></div>');
$.ajax(
{
url: '/Deal/Index',
type: "POST",
data: ({ toets: itemNo }),
dataType:'html',
success: function (result) {
$(dialogDIV).html(result);
$(dialogDIV).dialog({
position : [,100],
error: function (req, status, error) {
alert(error);
}
});
},
error: function (req, status, error) {
alert(error);
}
})
return false;
}
Run Code Online (Sandbox Code Playgroud)
控制器动作
public ActionResult Index(int toets,string vendorNo)
{
string temp = toets.ToString();
string tempdd = Request.QueryString["vendorNo"];
//return Content("1212121212");
return PartialView();
}
Run Code Online (Sandbox Code Playgroud)
toets参数从ajax函数传递,但我现在需要Querystring中的vendorNo.
谢谢
编辑:我知道我可以添加一个javascript函数来从查询字符串中获取值,但这是最好的方法吗?