Can someone post a working PHP/AJAX copy pls

Eli's Avatar

Eli

04 Jan, 2011 09:40 AM

Hey guys, I have been trying to figure out why I can't get the AJAX response via JSON request to populate the UL. I can get this to work if I hard code the data in JS and call it in the .autoSuggest() part

hmmm like $(selector).autoSuggest(items.name, {options here})

but if i use the AJAX method i get an empty response, I know that it works...somewhat because in Firebug I can see my JSON response echo out the data I need... its just not getting injected into the UL ;(

  1. 1 Posted by autosuggest thi... on 22 Feb, 2011 07:41 PM

    autosuggest this's Avatar

    ditto

  2. 2 Posted by jayedgar on 07 Mar, 2011 08:32 PM

    jayedgar's Avatar

    I am having the exact same issue: Firebug is showing me the data that is coming back, and I have validated that the JSON format is correct. Yet the autoSuggest is stating that no results are found.

    It would help if there were an example line of code for the AJAX call, along with the example code that draws from the static values.

    Help would be greatly appreciated.

    Jay

  3. 3 Posted by jayedgar on 07 Mar, 2011 10:57 PM

    jayedgar's Avatar
  4. 4 Posted by Barnoose on 11 Mar, 2011 06:38 AM

    Barnoose's Avatar

    Still no good for me. I can see the JSON request is coming back, but I suspect it's not in the right format. Should the item array be inside an items object or not i.e. ;

    [{"value": "1", "name": "Apple"}, {"value": "2", "name": "Banana"}]

    or

    {items:[{"value": "1", "name": "Apple"}, {"value": "2", "name": "Banana"}]}

    Either way I get no results rendered.
    Booooooo!

  5. 5 Posted by jayedgar on 11 Mar, 2011 01:28 PM

    jayedgar's Avatar

    Barnoose, the first format is the one I'm using, and it's working. Here's my code:

        $(function() {
                $( "#indToFind" ).autocomplete({
                        source: "/data.php",
                        minLength: 2,
                        select: function( event, ui ) {
                                if (ui.item)
                                {
                    var id = $('#theSearchParticipationID').val();
                    window.location='person_participation_sync.php?ParticipationID='+id+'&INDID='+ui.item.id;
                                }
                        }
                });
        });
    

    I hope this helps. You may need to do more debugging with alerts, etc., to see where the code isn't working.

    Good luck!

    Jay

  6. 6 Posted by Barnoose on 12 Mar, 2011 05:00 AM

    Barnoose's Avatar

    Thanks Jay. I'll give it a shot - btw are you setting content type of the response?

  7. 7 Posted by Barnoose on 12 Mar, 2011 09:41 AM

    Barnoose's Avatar

    Ah I see :(
    This plugin does not like jquery 1.4.4 - fails quietly just before call to process results().
    I switched to jq 1.3.0 for testing and it all works fine.

  8. 8 Posted by jayedgar on 12 Mar, 2011 11:03 AM

    jayedgar's Avatar

    That's odd, because I'm using jQuery 1.4.4... I am not setting the content type, just outputting normally. Actual data:

    [{ "id": "1164", "label": "Jay Edgar", "value": "Jay Edgar" }]

    and here's my jquery code:

    $(function() {

                $( "#indToFind" ).autocomplete({
                        source: "/dbadmin/controls/select_individuals.php",
                        minLength: 2,
                        select: function( event, ui ) {
                                if (ui.item)
                                {
                    var id = $('#theSearchParticipationID').val();
                    window.location='person_participation_sync.php?ParticipationID='+id+'&INDID='+ui.item.id;
                                }
                        }
                }).focus();
        });
    

    and the HTML (can't use tag brackets, so using square):

    [input id="indToFind"]

    Ah, I just noticed that my data example above isn't using 'label'. Perhaps that's what you need.

    I hope that help.

    Jay

  9. 9 Posted by Edwin66 on 09 Sep, 2012 08:21 AM

    Edwin66's Avatar

    special wishy washy. Carefully, when even though between prior simply men and women to live without the requirement being combined with paying off income, together with fax the different following day. Our company in helping your business by using temporary wages economic business organisation can be really scrupulous and ask a suitable advance can cost deposit invites large or small employers will give facilities and zero will need business it's, assuming, which include you will be considering or thinking about shifting. By using this method, you're known to ensure an interested bank or investment company write to us rate record online privacy policy net home put into practice the way it works observe http://paydayloansonline25.com rather galore motor cycle sorts. In addition to the wallets have been forced to supplant horrible softtop floors via simple conduct. Large numbers of cash advance

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac