我有一个 asp.net mvc4 应用程序,我将在其中使用.post
ajax 的函数在我的视图中发布一个变量。我有这个问题,我把它贴在这里:问题,所以我现在试图通过使用来解决它Ajax
查看:index.cshtml
<td>
<a href="#" onClick="openbox2('Validation de concept technique', 1)" data-arr="@fa.Id_element">Donner votre avis</a>.
</td>
和
<form method="Post" action="/User/Validate_Expert_Decision" target="_parent">
<span>
<b style="color:red" >
Votre justification *
<b />
<br />
<br />
<textarea rows="10" cols="75" name="justification"></textarea>
</span>
<input type="hidden" name="element" value="@Request.Params["element"]" />
<p>
<input type="submit" name="submit">
<input type="button" name="cancel" value="Annuler" onClick="closebox()">
</p>
</form>
javascript函数
function openbox2(formtitle, fadin) {
var self = $(this);
var arr = self.data('arr');
$.post("/index.cshtml", { element: arr });
var box = document.getElementById('box');
document.getElementById('shadowing').style.display = 'block';
var btitle = document.getElementById('boxtitle');
btitle.innerHTML = formtitle;
if (fadin) {
gradient("box", 0);
fadein("box");
}
else {
box.style.display = 'block';
}
}
控制器:Validate_Expert_Decision
public ActionResult Validate_Expert_Decision()
{
string id_element = Request.Params["element"];
return RedirectToAction("Display_Task_List", new { id_project = id_project});
}
问题是我总是得到一个空值id_element
in string id_element = Request.Params["element"];
。
这个错误的原因是什么?我该如何解决?