WordPress ajax call takes too long

Discussion in 'PHP' started by stephan2307, Jan 6, 2015.

  1. #1
    So I am doing a custom ajax call in WordPress. The problem is that it is quite a big task that this ajax call is doing and before it completes the task WordPress presents me with a 404 error page

    Has anyone else had this experience? Any solution for this?
     
    stephan2307, Jan 6, 2015 IP
  2. billzo

    billzo Well-Known Member

    Messages:
    961
    Likes Received:
    278
    Best Answers:
    15
    Trophy Points:
    113
    #2
    A 404 code is a "Not Found" error. I do not know why a 404 would be returned. Usually that happens when a file does not exist. Could this be a timeout problem, such as exceeding PHP's max_execution_time? Or perhaps the web server timing out?
     
    billzo, Jan 6, 2015 IP
  3. cmscoders

    cmscoders Greenhorn

    Messages:
    2
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    23
    #3
    404 is Page not found error, I think there is the path issue of php file which you called in ajax
     
    cmscoders, Jan 7, 2015 IP
  4. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #4
    If you're doing an Ajax-call, it should NOT end in a 404 - an ajax-call should return an error or nothing at all if the source isn't found, or similar. As others have stated, a 404 error means the page you're trying to reach isn't there - and as this is an ajax-call, it shouldn't redirect - it should load the content (or whatever you're fetching via ajax) on the page you're already on. What exactly are you trying to do?
     
    PoPSiCLe, Jan 7, 2015 IP
  5. Googl

    Googl Active Member

    Messages:
    509
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    75
    #5
    Are you loading wordpress on a custom page outsite of wordpress i.e; using: require($wordpress_dir.'/wp-blog-header.php');? You may want to add: header("HTTP/1.1 200 OK"); on the page. This is a common problem for ajax requests in Wordpress. Add the header after loading wordpress to replace Wordpress 404 header.
     
    Googl, Jan 8, 2015 IP
  6. ezprint2008

    ezprint2008 Well-Known Member

    Messages:
    611
    Likes Received:
    15
    Best Answers:
    2
    Trophy Points:
    140
    Digital Goods:
    1
    #6
    your ajax string to pass variables and pull data back for PHP is obviously pulling a URL back instead of raw data and is trying to access a bad or non-existent URL
    re-read your multiple string Ajax code where youre passing the vars GET methods . not the top 'engine' code, only at bottom with the stack of GET method var passing method, youre pulling a URL or what the PHP on return is using like a header or page redirect. If it for sure isnt any of that, then your htaccess file might be redirecting for whatever reason and you forgot that it was doing that.
     
    ezprint2008, Jan 12, 2015 IP