我正在尝试为我的隐藏字段分配一个值并在我的控制器中访问它,在隐藏字段中分配值后,我将执行一个删除操作,在该函数结束时将重新加载页面,这是它的位置将再次访问我的'SearchResult'ActionResult,但是我无法获得隐藏字段值,请在这里帮助我做错了。感谢:
<script type="text/javascript">
function storeValues() {
var searchString = $('#searchString').val();
$("#storeFields").val(searchString);
}
function confirmDeletion() {
$.ajax({
cache: false,
type: "POST",
url: '@(Url.Action("DeleteEntry", "Admin"))',
data: '{"id": "' + delId + '"}',
contentType: "application/json; charset=utf-8",
success: function (msg) {
if (msg.data === "success") {
$('#deleteModal').modal('hide');
$('#hideButton').hide();
location.reload();
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) { }
});
}
</script>
<input type="hidden" id="storeFields" name="storeFields" />
<input type="image" id="searchbutton" onclick="storeValues();" src="@Url.Content("~/images/magnifying-glass.png")" width="30" height="30"/>
[HttpGet]
[Authorize]
[AcceptVerbs(HttpVerbs.Get)]
public ActionResult SearchResult(int? page, string storeFields)
{
var entries = unitOfWork.EntryRepository.GetAllWinners_SearchByEmail("True", "", 1);
var day = 1;
var pageNumber = page ?? 1;
var onePageOfEntries = entries.ToPagedList(pageNumber, 10);
if (day == 2)
{
return View("DayTwo", onePageOfEntries);
}
return View("Index", onePageOfEntries);
}
答案 0 :(得分:0)
您可以使用location.reload()
将隐藏字段值作为查询字符串传递而不是window.location.replace(url)
。