私はこのような私のmasterlayoutでActionLinkのを持っている:
@Html.ActionLink("Order Your Free Report 1", "CheckValue", "Product", null,new { id = "checkExists" })
私はこのようなアクションメソッドがあります。
public ActionResult CheckValue() {
bool result = true;
ViewData["checkCondition"] = true;
return Json(result, JsonRequestBehavior.AllowGet);
}
や機能などをこれは:
$(function() {
$('#checkExists').click(function() {
$.getJSON(this.href, function (result) {
alert(result);
if (result) {
alert('the record exists');
}
});
return false;
});
});
私がリンクをクリックすると、警告は表示されません。しかし、私はこのように使用する場合:
$(function() {
$('#checkExists').click(function() {
var condition =new Boolean('@ViewData["checkCondition"]');
if (condition) {
alert("message");
}
return false;
});
});
それは動作します。なぜ最初に動作していないのかをお聞かせください。
現れるものを教えて
this
$(this)
にをラップしてみてくださいあなたがいるかどうか確認するためにFirebugのか、他のブラウザのデバッガのようなものを使用しましたHTTPリクエストが作成されていますか?どこにエラーが報告されていますか? – Pointy
firebugを使ってチェックするあなたのリンクの 'href'属性の値は何ですか? – Rafay
@ 3nigma:linkはfirebugのhtmlウィンドウで次のようになります。Order Your Free Report 1 – DotnetSparrow