我如何通过正确的Url.Action到jQuery的方法,无需额外的符号烦恼吗? [英] How do I pass correct Url.Action to a JQuery method without extra ampersand trouble?

查看:120
本文介绍了我如何通过正确的Url.Action到jQuery的方法,无需额外的符号烦恼吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让Ajax调用就像这样:

I am trying to make an ajax call like so:

$('#Grid').load('@Url.Action("_AgentStatesGrid", "AgentStates", new { projectId = Model.SelectedProject, siteId = Model.SelectedSite })', null, refreshComplete);

不幸的是,它得到PTED因为这间$ P $:

Unfortunately, it gets interpreted as this:

$('#Grid').load('/AgentStates/_AgentStatesGrid?projectId=179&siteId=0', null, refreshComplete);

正如你所看到的,和放大器; .a.m.p;是符号的查询字符串的存在,而不是(我放点,因为,咄,网页跨$ P $点它作为一个符号......,你的想法)

As you can see, the &.a.m.p.; is there instead of the ampersand for the querystring (I put dots in because, duh, the web interprets it as an ampersand.., you get the idea)

我试过Url.De code,而没有采取任何行动。我不知道我理解的问题,所以我不知道如何解决它。

I tried Url.Decode and that did nothing. I'm not sure I understand the problem so I have no clue how to fix it.

推荐答案

尝试

 @Html.Raw(Url.Action("_AgentStatesGrid", "AgentStates", new { projectId = Model.SelectedProject, siteId = Model.SelectedSite })) 

感谢

这篇关于我如何通过正确的Url.Action到jQuery的方法,无需额外的符号烦恼吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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