Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery ui automplete + json data from php
    primarykey
    data
    text
    <p>I'm trying to make autocomplete of a field with jquery ui autocomplete and json, data from php file... But can't get any results...</p> <p>Here is my jquery code:</p> <pre><code>$('#rech_abo').keyup(function(e) { e.preventDefault(); $( ".find_group_ac" ).autocomplete({ minLength: 3, source: function(request, response) { $.ajax({ url: "/chercheabo", data: {achercher : $("#rech_abo").val()}, dataType: "json", type: "POST", success: function(data) { response($.map(data, function(obj) { return { label: obj.pseuDO, value: obj.userID, // description: obj.description // id: obj.userID // don't really need this unless you're using it elsewhere. }; })); } }); } }).data( "autocomplete" )._renderItem = function( ul, item ) { // Inside of _renderItem you can use any property that exists on each item that we built // with $.map above */ return $("&lt;li&gt;&lt;/li&gt;") .data("item.autocomplete", item) .append("&lt;a&gt;" + item.label + "&lt;br&gt;" + item.description + "&lt;/a&gt;") .appendTo(ul); }; }); </code></pre> <p>My php:</p> <pre><code>$options = array(); $result = mysqli_query($link,"select userid, pseudo from utilisateurs where pseudo like '%".strtolower($_POST[achercher])."%'"); while($uti = $result-&gt;fetch_object()) { $options['myData'][] = array( 'userID' =&gt; $uti-&gt;userid, 'pseuDO' =&gt; $uti-&gt;pseudo, 'retourDATA' =&gt; $retour_data ); } echo json_encode($options); </code></pre> <p>And my html:</p> <pre><code>&lt;div class=\"abo_parnom\"&gt;&lt;input class=\"input_text_compte\" type=\"text\" placeholder=\"Tappez un nom\" id=\"rech_abo\"&gt; &lt;input type=\"button\" id=\"rech_abo_valider\" class=\"bouton_suppr\" value=\"Ok\"&gt;&lt;/div&gt; </code></pre> <p>Any idea what is missing here? Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload