いつも「エラー」アラートが表示され、何が間違っているかわかりません。私はちょうど私が送る文字列( "testexpression")を取得しようとしています。パラメタがなければ、それはデータ部分と何かでなければなりません。ここで jquery ajaxでデータを渡す
はjqueryの一部です:<script>
$("#meaning").blur(function() {
$.ajax({
type: "POST",
url: '/GetMeaning/',
data: {"expression" : "testexpression"},
contentType: "application/json; charset=utf-8",
dataType: "json",
success: successFunc,
error: errorFunc
});
function successFunc(data, status) {
$("#dictionaryDropDown").html(data);
}
function errorFunc() {
alert('error');
}
})
</script>
そして、これはコントローラです:
public class GetMeaningController : Controller
{
//
// GET: /GetMeaning/
[HttpGet]
public ActionResult Index()
{
return View();
}
[HttpPost]
public ActionResult Index(string expression)
{
return Json(expression, JsonRequestBehavior.AllowGet);
}
}
(更新:タイプはポストですが、私はちょうど同様に取得して、それを試して、私ました