Salve ragazzi, sto cercando di realizzare una text box con la funzione di completamento automatico eseguendo una query ad un server apache Solr.
Il codice è il seguente:
Il risultato della query è il seguente:codice:!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>jQuery UI Autocomplete - Remote JSONP datasource</title> <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css"> <script src="//code.jquery.com/jquery-1.9.1.js"></script> <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script> <link rel="stylesheet" href="/resources/demos/style.css"> <style> .ui-autocomplete-loading { background: white url('images/ui-anim_basic_16x16.gif') right center no-repeat; } #city { width: 25em; } </style> <script> <SCRIPT type="text/javascript"> $(function() { $("#autotextsearch").autocomplete({ source: function( request, response ) { $.ajax({ url: "http://127.0.0.1:8983/solr/suggest?spellcheck.q="+request.term+"&wt=json", jsonp: 'json.wrf', data: { q: request.term, }, success: function(data) { response( $.map(data.suggestions.suggestion, function(item,i) { return { value: item.suggestion } })); } }); }, minLength: 2 }); }); </SCRIPT> </head> <body> <f:view> <label for="autotextsearch">Search Here : </label> <input id="autotextsearch"/> </f:view> </body> </html>
Non ottengo nessun errore, ma non compaiono i suggerimenti nella texboxcodice:{"responseHeader":{"status":0,"QTime":1},"spellcheck":{"suggestions":["notizi",{"numFound":5,"startOffset":0,"endOffset":6,"suggestion":["notizia","notizia a","notizia a favore","notizia a favore di","notizia al"]}]}}

Rispondi quotando
