MemoryRefresh!

Autocomplete



Questions Answers 0%

Pages   0 from 18
Questions   0 from 23

Reset




<?php if (@$_GET['keyword']) { $arr = array('Arad', 'Alba', 'Bucuresti', 'Brasov', 'Covasna', 'Cluj'); $matches = array(); foreach($arr as $v) { if (stripos($v, $_GET['keyword']) === 0) { array_push($matches, $v); } } echo json_encode($matches); die; } ?> <script type="text/javascript" src="http://refresh.local/lib/js/jquery-latest.js"></script> <script type="text/javascript" src="http://refresh.local/lib/js/jqueryui/jqueryui-min.js"></script> <link href="http://refresh.local/lib/js/jqueryui/themes/jqueryui.css" media="screen" rel="stylesheet" type="text/css" /> <input type='text' id='editable_autocomplete' name='editable_autocomplete'> <script type='text/javascript'> // autocomplete $(function() { var cache = {}; var lastXhr; $( "#editable_autocomplete" ).autocomplete({ minLength: 1, source: function( request, response ) { var term = request.term; if ( term in cache ) { response( cache[ term ] ); return; } lastXhr = $.getJSON( "test.php?keyword="+term, function( data, status, xhr ) { cache[term] = data; if ( xhr === lastXhr ) { response( data ); } } ); } }); }); </script>
Questions

Related pages

Request !
Ajax post !
Ajax cross domain !
Autocomplete !
Combobox related !


0% 100%
 
 
0 pages 18 pages
No questions


<?php if (@$_GET['keyword']) { $arr = array('Arad', 'Alba', 'Bucuresti', 'Brasov', 'Covasna', 'Cluj'); $matches = array(); foreach($arr as $v) { if (stripos($v, $_GET['keyword']) === 0) { array_push($matches, $v); } } echo json_encode($matches); die; } ?> <script type="text/javascript" src="http://refresh.local/lib/js/jquery-latest.js"></script> <script type="text/javascript" src="http://refresh.local/lib/js/jqueryui/jqueryui-min.js"></script> <link href="http://refresh.local/lib/js/jqueryui/themes/jqueryui.css" media="screen" rel="stylesheet" type="text/css" /> <input type='text' id='editable_autocomplete' name='editable_autocomplete'> <script type='text/javascript'> // autocomplete $(function() { var cache = {}; var lastXhr; $( "#editable_autocomplete" ).autocomplete({ minLength: 1, source: function( request, response ) { var term = request.term; if ( term in cache ) { response( cache[ term ] ); return; } lastXhr = $.getJSON( "test.php?keyword="+term, function( data, status, xhr ) { cache[term] = data; if ( xhr === lastXhr ) { response( data ); } } ); } }); }); </script>



More from Jquery

Data
Effects
Window
Attributes
Element
Basics
Ajax
Form
Uncategorized


More from Programming

Php
jQuery




Powered by minte9.com