last day (14 days later) » 

1:03 PM
0
Q: Replacing contents of main view with partial view

Johnathon64I have written some jquery which performs a get on an action, passing in a dashID and hopefully should have returned some html with the relevant information. However my jquery does not seem to be getting that data back. Here is my javascript function loadDashboard(dashID) { $.get('@Url.Act...

 
you try pass parameter from client function to server code '@Url.Action("Dashboard", new {id = ' + dashID + '})'. In many places you mix razor markup and js.
 
I was following one of the previous posts hoping that it would work. This seemed to be the way that they were doing it.
 
in sample by link not used client variables, just hardcore value 'A'
can you provide route for your action? possibly '@Url.Action("Dashboard")' + '?id='+dashID will be enough
yet another variant '@Url.Action("Dashboard", new {id = -1})'.replace(/-1/, dashID)
@DawoodAwan it not work, because dashID client variable, and @Url.Action render on server
 
I have tried all the suggestions that you guys have supplied but these still don't seem to work
 
@Johnathon64, how it not work? errors in console? error in ajax call? nothing happens? error when page load?
 
1:03 PM
Nothing happens, I have firebug running and no errors javascript side. I put a breakpoint on the javascript code, it passes in the ID fine, however no content is being brought back.
 
can you show rendered function?
 
@Grundy What do you mean the rendered function?
 
@Johnathon64, i mean script when loaded in browse without razer markup
also where placed your script? in a separate file, or in page directly?
what happens when you click to this li?
 
1:17 PM
hey grundy
my script is in another file
and this is what it looks like
function loadDashboard(dashID) {
$.get('@Url.Action("Dashboard")' + '?id=' + dashID, function (data) {
$('#dash-content').html(data);
});
}function loadDashboard(dashID) {
$.get('@Url.Action("Dashboard")' + '?id=' + dashID, function (data) {
$('#dash-content').html(data);
});
}
when i clck li
it fires the js code but does not bring back any data
 
1:36 PM
@Johnathon64 if your script in another file, so razor simple not process it
@Johnathon64, you need move this function to your page, or use global variable vith path and use it in your function
@Johnathon64 do you see error in console when on click? i guess would be error 404 for url
 
@Johnathon64 I have posted an answer both with seperate JS file and with without JS file
 
1:54 PM
ok I will have a look
 

last day (14 days later) »