I'm attempting to AJAX in an MVC View to an empty tag using the standard jQuery AJAX call:-
function AjaxLoadPanel(url, id) {
var a = 1;
$.ajax({
url: url,
cache: true,
type: "GET",
success: function (data) {
if (data == "PageNotFound") {
window.location = "page-not-found";
}
else {
$(id).html(data)
}
},
error: function (response) {
$(id).html("");
}
});
}
The MVC controller simply returns the View with an MVC form within, and a HTTP Post beyond that to accept form data. When I put the pages with the div tag and the DLL and views on the server however, there is significant lag before the div tag is populated with the view return from the AJAX call. When I say significant lag, I mean 30 to 60 seconds after the page has loaded. The AJAX call does eventually finish, but such a problem renders the page useless to the unsuspecting user.
Stuff I've checked:-
- All scripts are local to the site, no calls to external JS files.
- All CSS are local to the site, no external calls.
- The view and DLL's are definitely in the correct place
- There are no scripts in the head tag.
- The view does eventually get AJAX'd into the correct panel.
- The wait time comes from calling the view specifically. Navigating to the URL of the view results in a 30 - 60 second wait before the view is returned.
How can I speed up the retrieval of the view? I need it to be within 1 second of page load if at all possible? Also, on localhost this feature works at lightning speed, loading in around 0.2 / 0.3 seconds.
Could it be the server being slow?
Thanks! Mike.
