使用Ajax.ActionLink MVC2时,参数列表错误后失踪) [英] missing ) after argument list error when using Ajax.ActionLink mvc2

查看:123
本文介绍了使用Ajax.ActionLink MVC2时,参数列表错误后失踪)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我这有ActionLink的是产生在Firefox这个错误

I've got this actionlink that is generating this error in firefox

<%: Ajax.ActionLink(" ", "SelectEditProduct", new { id = item.Id }, new AjaxOptions { UpdateTargetId = "dialog", InsertionMode = InsertionMode.Replace, OnSuccess = "$(\"#dialog\").dialog(\"open\");"}, new { Class="edit"})%>

这似乎是从一些JavaScript代码片段我来了。我躲过了报价,但这样我很为难。

It seems to be coming from the little javascript snippet I have. I escaped the quotations though so I'm stumped.

推荐答案

我在这里看到的是,你正在使用jQuery一起使用Microsoft AJAX。这两个有什么理由在同一个项目中混合,如果你已经有jQuery的另一种是完全无用的。因此,而不是污染您的标记使用javascript,不知道如何逃避单引号和双引号用斜杠,并获得大量的错误的,这样做不显眼(jQuery的方式):

What I see here is that you are using jQuery alongside with Microsoft AJAX. Those two have no reason to be mixed in the same project and if you already have jQuery the other is completely useless. So instead of polluting your markup with javascript and wondering how to escape single and double quotes with slashes and get plenty of errors, do it unobtrusively (the jQuery way):

<%: Html.ActionLink(
    "Some link text", 
    "SelectEditProduct", 
    new { id = item.Id }, 
    new { @class = "edit" }
) %>

和一个单独的 js文件:

$(function() {
    $('a.edit').click(function() {
        // When a link with class="edit" is clicked
        // send an AJAX request to the href and replace the result
        // of a DOM element with id="dialog" with the response
        // returned by the server
        // Also when the request completes show a jQuery dialog.
        $('#dialog').load(this.href, function() {
            $('#dialog').dialog('open');
        });
        return false;
    });
});

这篇关于使用Ajax.ActionLink MVC2时,参数列表错误后失踪)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆