for example:
current url : localhost/website
becoming : localhost/website/product
without refreshing.
Thanks in advance
for example:
current url : localhost/website
becoming : localhost/website/product
without refreshing.
Thanks in advance
Yes it is possible but don't use Ajax.ActionLink.
Keep it simple - use jQuery - then you have total control:
$(function() {
$('#somelink').click(function(e) {
e.preventDefault();
get('/controller/action1', function(data) {
$('#up').html(data);
});
$.get('/controller/action2', function(data) {
$('#down').html(data);
});
});
});
You should use Url.Action or Url.RouteUrl to generate the URL for the AJAX call, so if your routes change then your JS need not, e.g:
.get('@Url.Action('Controller', 'Action1')', function(data)
or
.get('@Url.RouteUrl('SomeNamedRoute')', function(data)
If your putting this script in an external file then you'll need to use a technique to set the url in the main view, then read from the external variable.
Such techniques include a JavaScript variable, hidden field, passing URL to function as parameter, etc.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.