Javascript parameter does not exist in current context

why doesn't it work? How can I declare them? given that topicid will be 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

+4
source share
1 answer

According to @alxndr's hint, this question has the same error, and it is solved with the following code:

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'); 
    });
}

, JavaScript (topicid topicname) Razor - view. , . , @Url.Action JavaScript, JavaScript ( ) joker chars -1 -2 . , , . , .

+7

All Articles