admin管理员组文章数量:1415484
why doesnt this work? how can i declare these? considering topicid will be an int and topicname will be a string.
function changetotopicdetail(topicid, topicname) {
$('#loadingAjaxs').show();
$('#flubestext').hide();
$('#contentwrap').load('@Url.Action("Detail", "Topics", new { @id = topicid, @namespace = topicname, @Forum = "all", @page = 0})', function () {
$('#loadingAjaxs').hide();
$('#flubestext').show();
window.history.pushState(null, 'title', '/topics');
})
}
thanks
why doesnt this work? how can i declare these? considering topicid will be an int and topicname will be a string.
function changetotopicdetail(topicid, topicname) {
$('#loadingAjaxs').show();
$('#flubestext').hide();
$('#contentwrap').load('@Url.Action("Detail", "Topics", new { @id = topicid, @namespace = topicname, @Forum = "all", @page = 0})', function () {
$('#loadingAjaxs').hide();
$('#flubestext').show();
window.history.pushState(null, 'title', '/topics');
})
}
thanks
Share Improve this question edited Sep 28, 2013 at 16:21 Imran 5047 silver badges15 bronze badges asked Sep 28, 2013 at 13:32 mxadammxadam 1672 silver badges14 bronze badges 3- see answer here: stackoverflow./questions/9751109/… – alxndr Commented Sep 28, 2013 at 13:36
- i dont see how that has any relevence to my question? – mxadam Commented Sep 28, 2013 at 13:42
- @alxndr posted a question that is totally relative to yours... is the same mistake you're doing on this. – DontVoteMeDown Commented Sep 28, 2013 at 13:48
1 Answer
Reset to default 8According to @alxndr tip, this question has the same mistake and it is solved with a code like that:
function changetotopicdetail(topicid, topicname) {
$('#loadingAjaxs').show();
$('#flubestext').hide();
var link = '@Url.Action("Detail", "Topics", new { @id = -1, @namespace = -2, @Forum = "all", @page = 0})';
link = link.replace("-1", topicid);
link = link.replace("-2", topicname);
$('#contentwrap').load(link, function () {
$('#loadingAjaxs').hide();
$('#flubestext').show();
window.history.pushState(null, 'title', '/topics');
});
}
You mistake is that you're trying to access two JavaScript variables(topicid
and topicname
) in the Razor - view - context. Razor can't access it, so those two variables are unknown for it. What the code is doing is to print the @Url.Action
result on a JavaScript variable and then, in JavaScript (where you can access those parameters) replace that link joker chars -1
and -2
with the parameters. So you got the link the way you need it. Hope my explanation is clear.
本文标签: aspnet mvcjavascript parameter doesnt exist in the current contextStack Overflow
版权声明:本文标题:asp.net mvc - javascript parameter doesnt exist in the current context - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745233782a2648938.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论