WordPress.org

Ready to get started?Download WordPress

Forums

autocomplete just not working! (8 posts)

  1. pbaker21
    Member
    Posted 1 year ago #

    Hi,
    It's been a very LONG day, and I'm not even sure if I'm in the right place to ask this question.

    I'm trying to get autocomplete (see below) to work but, although it's half working, bare with me. It is connecting to the php script and I'm getting the 'wait' icon in the query box. It's just not giving me any data back.

    wp_enqueue_script('jquery-ui-autocomplete', '', array('jquery-ui-widget', 'jquery-ui-position'), '1.8.6');

    wp_register_script('js-script1', plugins_url('auto04.js', __FILE__), array('jquery'));
    wp_enqueue_script('js-script1');

    ////////////////////// This code is in file named: auto04.js

    jQuery(document).ready(function($) {

    //var availableTags = ["Batman", "Spiderman", "Hulk"];

    $("#query1").autocomplete({
    source: 'http://www.comparetrainfares.co.uk/wp-content/train_scripts/test-suggest-simple.php',
    dataType: 'json',
    remoteSourceStatic: true,
    minLength: 3
    });
    });

    //////////////////////////////////////////////////////

  2. Andrew
    Forum Moderator
    Posted 1 year ago #

    Which theme are you using?

  3. pbaker21
    Member
    Posted 1 year ago #

    I created the theme using Artisteer. I'm not sure if this it is important to mention that my WordPress in on localhost at the moment (whilst I play).

    Thanks.

  4. Andrew
    Forum Moderator
    Posted 1 year ago #

    Have you checked your browser's console log for (JavaScript) errors?

  5. pbaker21
    Member
    Posted 1 year ago #

    yeah, that's the odd thing, no errors!

    Once I've typed something - All I see is:

    http://www.comparetrainfares.co.uk/wp-content/train_scripts/test-suggest-simple.php?term=hulk 200 OK 289ms

    I then have below that:
    -------------------------------------
    Params Headers Response HTML
    -------------------------------------

    Params, shows: term hulk

    Headers, show :

    Response Headers
    Connection Keep-Alive
    Content-Encoding gzip
    Content-Length 76
    Content-Type text/html
    Date Tue, 20 Nov 2012 19:56:15 GMT
    Keep-Alive timeout=1, max=100
    Server Apache/2.2.16 (Debian)
    Vary Accept-Encoding
    X-Powered-By PHP/5.3.3-7+squeeze13
    Request Headers
    Accept application/json, text/javascript, */*; q=0.01
    Accept-Encoding gzip, deflate
    Accept-Language en-US,en;q=0.5
    Connection keep-alive
    DNT 1
    Host http://www.comparetrainfares.co.uk
    Origin http://localhost
    Referer http://localhost/wordpress/some-other-page/
    User-Agent Mozilla/5.0 (Windows NT 5.1; rv:16.0) Gecko/20100101 Firefox/16.0

    Response and HTML, shows nothing!

  6. pbaker21
    Member
    Posted 1 year ago #

    It's ok now!! I've managed to solve the problem.

    It turns out I just need to add:

    header("Access-Control-Allow-Origin: *");

    At the top of my (remote) Php script. PHEW....!

  7. pbaker21
    Member
    Posted 1 year ago #

    Hold them horses! Just when I thought I had it sussed, I tried it in IE!!!!!

    It works in Chrome and FireFox but, not IE. I've thrown everything at it. I'm now fully depleted on what to do next.

    I thought : header("Access-Control-Allow-Origin: *");
    would ave solved the problem. It's always IE, every time! Ahhhhhhhhh

    Any thoughts, ideas welcome.

  8. RonStrilaeff
    Member
    Posted 1 year ago #

    I have a need for this and will dive in soon get it working.

    Are you basing your code on this jQuery UI?

Topic Closed

This topic has been closed to new replies.

About this Topic