I'm使搜索框獲得視的價值我的數據庫的一個寄存器sended,所以在我看來:獲取參數控制器
<p> Manifest: <input type="text" name="manifest" id="manifest" /> <input type="submit" value="search" name="btnGetForEdith" id="btnGetForEdith" /></p>
JS:
$(document).ready(function() {
GetModulLogWasteForEdit();
$("#btnGetForEdith").click(onGetModulLogWasteSuccess);
});
function GetModulLogWasteForEdit() {
currentId = 0;
try {
$(function() {
$.ajax({
cache: false,
type: "get",
dataType: "json",
url: "/LogWaste/GetForEdit",
contentType: "application/json; charset=utf-8",
success: onGetModulLogWasteSuccess,
error: function (response) {
ErrorMessage("Error", GetTextError(response));
}
});
});
} catch (e) {
ErrorMessage("Error", e.message);
}
}
控制器:
public ActionResult GetForEdit(string manifest)
{
string result = string.Empty;
var userId = User.Identity.GetUserId();
var currentUser = UserClass.GetUserBranchOfficeId(userId);
try
{
result = new JavaScriptSerializer().Serialize(LogWasteModule.GetForEdit(currentUser));
}
catch (Exception)
{
throw;
}
return Content(result, "application/json");
}
問題是我不明顯的價值進入我的控制器它來了null
所以我不能與它一起。任何人都可以解釋爲什麼會發生?問候
你缺少對Ajax調用數據參數...請參見本:http://stackoverflow.com/questions/15576548/how-to-pass-parameters-in-get-requests-with-jquery –