Current, it looks like you are making an AJAX request and then immediately reloading the page, which will cause your newly loaded content to disappear, which is worth noting. If you don't want this to occur, simply just update the content and don't navigate away.
Regarding Navigating
Set the window.location.href
attribute to handle this within your success block :
success:function(data) {
$("body").html(data);
$(".dropdown-toggle").dropdown();
// This will navigate to your preferred location
window.location.href = url;
},
Updating the URL without Navigating
If you wanted to update the content within the URL without actually navigating away, you could consider using an approach that relied on updating the history as opposed to navigating away using something like this via the history.pushState()
function :
success:function(data) {
$("body").html(data);
$(".dropdown-toggle").dropdown();
// This will navigate to your preferred location
history.pushState({},"Your Title,url);
},
Regarding Using an MVC URL Directly
At present, you currently have your URL hard-coded to a given location, which can work in some scenarios, however it can make your code frail if any changes occur.
A recommendation would be to store the proper URL (resolved from MVC) in a data attribute and then use it when performing your navigation as seen below :
<!-- HTML -->
<input id="Navbar-Search-Button" type="submit" class="btn btn-default" value="Search" data-url="@Url.Action("Action","Controller")" />
<!-- Javascript -->
$("#Navbar-Search-Button").click(function (e) {
// Resolve your URL here
let url = $(this).data('url');
SendToController(url);
return false;
});
function SendToController(url) {
var regNumber = $("#IDValue").val().trim();
$.ajax({
url: url,
data: { 'argument': regNumber },
type: 'GET',
cache: false,
success:function(data) {
$("body").html(data);
$(".dropdown-toggle").dropdown();
document.location = url;
},
error: function () {
$("#Dialog").dialog('open');
}
});
}