Support » Fixing WordPress » autocomplete just not working!

  • pbaker21

    (@pbaker21)


    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
    });
    });

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

Viewing 7 replies - 1 through 7 (of 7 total)
  • Moderator Andrew Nevins

    (@anevins)

    Which theme are you using?

    pbaker21

    (@pbaker21)

    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.

    Moderator Andrew Nevins

    (@anevins)

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

    pbaker21

    (@pbaker21)

    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!

    pbaker21

    (@pbaker21)

    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….!

    pbaker21

    (@pbaker21)

    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.

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

    Are you basing your code on this jQuery UI?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘autocomplete just not working!’ is closed to new replies.