Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I pass correct Url.Action to a JQuery method without extra ampersand trouble?

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

Unfortunately, it gets interpreted as this:

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

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)

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.

like image 863
Chris Holmes Avatar asked Sep 07 '11 15:09

Chris Holmes


1 Answers

Try

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

Thanks

like image 169
Steve Avatar answered Sep 23 '22 08:09

Steve