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

  • Home
  • SEARCH
  • 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 5844769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:20:24+00:00 2026-05-22T12:20:24+00:00

I’m been stuck on this problem for a while and I’m pretty sure it

  • 0

I’m been stuck on this problem for a while and I’m pretty sure it must be something quite simple that hopefully someone out there can shed some light on.

So, I’m currently using jQuery UI’s Autocomplete plugin to reference and external PHP which gets information from a database (in an array) and sends it to a JSON output.

From my PHP file (search.php) when I do this:

echo json_encode($items);

My output (when looking at the search.php file) is this:

["Example 1","Example 2","Example 3","Example 4","Example 5"]

Which is valid JSON according to jsonlint.com

The problem is that when I use jQuery UI’s Autocomplete script to reference the external search.php file, Chrome just gives me the following error:

GET http://www.example.com/search.php?term=my+search+term 404 (Not Found)

I have tried inputting the JSON code straight into the ‘Source:’ declaration in my jQuery, and this works fine, but it will not read the JSON from the external PHP file.

Please can someone help?

Here’s my code:

HMTL

<p class="my-input">
<label for="input">Enter your input</label>

<textarea id="input" name="input"
class="validate[required]"
placeholder="Enter your input here.">
</textarea>
</p>

jQuery

$(function() {

    $( "#input" ).autocomplete({
        source: "http://www.example.com/search.php",
        minLength: 2
    });
});

PHP

header("Content-type: application/json");

// no term passed - just exit early with no response
    if (empty($_GET['term'])) exit ;
    $q = strtolower($_GET["term"]);
// remove slashes if they were magically added
    if (get_magic_quotes_gpc()) $q = stripslashes($q);

include '../../../my-include.php';
global $globalvariable;

$items = array();

// Get info from WordPress Database and put into array
$items = $wpdb->get_col("SELECT column FROM $wpdb->comments WHERE    comment_approved = '1' ORDER BY column ASC");

// echo out the items array in JSON format to be read by my jQuery Autocomplete plugin
    echo json_encode($items);

Result

In browser, when information is typed into #input

GET http://www.example.com/search.php?term=Example+1 404 (Not Found)

Update: the real PHP url is here: http://www.qwota.co.uk/wp/wp-content/themes/qwota/list-comments.php?term=Your

Please help!

UPDATE: ANSWER

The answer to my problem has been pointed out by Majid Fouladpour

The problem wasn’t with my code but rather with trying to use WordPress’ $wpdb global variable as (as far as I understand) it includes it’s own headers, and anything outside of it’s usual layout will result in a 404 error, even if the file is actually there.

I’m currently trying to get around the problem by creating my own MySQL requests and not using WordPress’s global variables / headers.

PS. Majid, I’ll come back and give you a ‘helpful tick’ once StackOverflow lets me! (I’m still a n00b.)

  • 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-05-22T12:20:25+00:00Added an answer on May 22, 2026 at 12:20 pm

    Your apache server is sending wrong headers. Here is a pair of request and response:

    Request

    GET /wp/wp-content/themes/qwota/list-comments.php?term=this HTTP/1.1
    Host: www.qwota.co.uk
    User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Language: en-us,en;q=0.5
    Accept-Encoding: gzip, deflate
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Keep-Alive: 115
    Connection: keep-alive
    Cookie: __utma=142729525.1341149814.1305551961.1305551961.1305551961.1; __utmb=142729525.3.10.1305551961; __utmc=142729525; __utmz=142729525.1305551961.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)
    

    Response headers

    HTTP/1.1 404 Not Found
    Date: Mon, 16 May 2011 13:28:31 GMT
    Server: Apache
    X-Powered-By: PHP/5.2.14
    X-Pingback: http://www.qwota.co.uk/wp/xmlrpc.php
    Expires: Wed, 11 Jan 1984 05:00:00 GMT
    Cache-Control: no-cache, must-revalidate, max-age=0
    Pragma: no-cache
    Last-Modified: Mon, 16 May 2011 13:28:31 GMT
    Keep-Alive: timeout=5, max=100
    Connection: Keep-Alive
    Transfer-Encoding: chunked
    Content-Type: text/html; charset=UTF-8
    

    Response body

    ["Bake 'em away... toys.","Content precedes design. Design in the absence of content is not design, it\u2019s decoration.","Hanging on in quiet desperation is the English way.","I'm a reasonable man, get off my case.","Look at me, Damien! It's all for you!","Never get out of the boat... absolutely god damn right.","That gum you like is going to come back in style.","The secret to creativity is knowing how to hide your sources.","Things could be different... but they're not.","Your eyes... they turn me."]
    

    So, even though you receive back response from the server, it has HTTP/1.1 404 Not Found in the headers. Someone may be able to investigate this and provide a potential reason and solution.

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a jquery bug and I've been looking for hours now, I can't
I'm looking for suggestions for debugging... If you view this site in Firefox or
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I have just tried to save a simple *.rtf file with some websites and
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I want to count how many characters a certain string has in PHP, but

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.