0

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.

2
  • 1
    Since it is a get request you can simulate the behaviour simply by copy&pasting the request url to the address bar and hit enter. Also you can check time line at the developer tools of your browser in order to learn whether your server is slow or not. Commented Apr 27, 2015 at 10:43
  • looks to me like a missconfiguration on the server-side Commented Apr 27, 2015 at 10:58

2 Answers 2

1

Check your browser's network panel how long does the AJAX request takes to load.

I am quite sure it is problem with the backend/server. Are you 100% sure that the server backend code is same as your localhost backend code? Also do you use any database to retrieve the data. Could be also database issue.

I added example pic here

Sign up to request clarification or add additional context in comments.

Comments

0

We found the issue eventually. A datbase connection string login was wrong and the 30 second wait was always 30 seconds because of the length to try and connect to the database for, before causing an exception. At 30 seconds those views that don't directly rely on a database connection are still retrieved, hence the 30 second wait every time.

Thanks for your help! Mike.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.