Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8668331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:11:16+00:00 2026-06-12T18:11:16+00:00

I’ve been working on a project that required me to use Ajax. In the

  • 0

I’ve been working on a project that required me to use Ajax. In the past I have had no problems creating a project with it, but this time every request takes at least 1 second, which is ofcourse way too long.

I can’t give you the entire code, but I’ll share as much as possible. The requests are as follows:

/* *
 * Update the navigation screen
 */
    function UpdateNavigation() {
         $.ajax({
            type: "POST",
            url: "application/controllers/LocationController.php",
            dataType: "json",
            data: "action=GetSurroundings",
            success: function(data){
                $("#direction-north").html((typeof data.north != 'undefined' ? data.north : "") + '</br> North');
                $("#direction-west").html((typeof data.west != 'undefined' ? data.west : "") + '</br> West');
                $("#direction-center").html((typeof data.center != 'undefined' ? data.center : "") + '</br> Center');
                $("#direction-east").html((typeof data.east != 'undefined' ? data.east : "") + '</br> East');
                $("#direction-south").html((typeof data.south != 'undefined' ? data.south : "") + '</br> South');
            }
        });
    }

/* *
 * Update the current location
 */
    $('#navigation-list :button').click(function(event) {
        if (event.target.id == "direction-center")
            return;

         $.ajax({
            type: "POST",
            url: "application/controllers/LocationController.php",
            data: "action=SetLocation&value=" + event.target.id,
            success: function() {
                UpdateNavigation();
            }
        });
    });

As far as I know this could is fine. It might be a good idea to change it a little but it shouldn’t cause the delay as far as I know. The LocationController file is pretty big, but it uses a switch for different cases so the actual executed code isn’t that big.

Using FireBug I found out that it’s waiting for 1.01 seconds for the first request, and 1.00 second for the second request. I did some research and people told me that this might be because the server is too busy to handle your request properly so that’s why it’s taking so long. But that seems unlikely because the code and database are hosted locally. There shouldn’t be a conflict in requests either since they are executed one at a time.

I’m at a loss here. I have no idea how to start debugging this problem. Deleting parts of the code didn’t help because it would either stop executing alltogether or just take 1+ second. This leads me to believe the code is not the problem, although I could be wrong.

Any help would be greatly apreciated! If you need more information, please don’t hesitate to ask.

Edit: Some more digging around leads me to believe the queries inside the code may be at fault? If so, I’m using the following (pretty ugly) queries:

SELECT 
    character_location.block,
    character_location.location
FROM
    character_location
WHERE
    character_location.id = 1
LIMIT
    1



SELECT 
    zones.name,
    zones.location,
    zones.block
FROM
    zones
WHERE
    (
            `zones`.`location` = (".$getBlock['location']." - 1)
        AND
            zones.block = '".$playerBlock."'
    )
OR
    (
            `zones`.`location` = ".$getBlock['location']."
        AND
            zones.block = '".$playerBlock."'
    )
OR
    (
            `zones`.`location` = (".$getBlock['location']." + 1)
        AND
            zones.block = '".$playerBlock."'
    )
OR
    (
            `zones`.`location` = ".$getBlock['location']."
        AND
            zones.block = '".$playerBlockDown."'
    )
OR
    (
            `zones`.`location` = ".$getBlock['location']."
        AND
            zones.block = '".$playerBlockUp."'
    )
LIMIT
    5


UPDATE 
    character_location
SET
    character_location.block = '" . $targetBlock . "',
    `character_location`.`location` = " . $targetLocation . "
WHERE
    character_location.id = 1

Guess which one I think might be causing the problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T18:11:17+00:00Added an answer on June 12, 2026 at 6:11 pm

    If you are using PDO for the connection.

    Instead of using localhost as the host use 127.0.0.1

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
This could be a duplicate question, but I have no idea what search terms
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I know there's a lot of other questions out there that deal with this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.