1
<html lang="en">
<head>
    <title>Bootstrap Typeahead with Ajax Example</title>  
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-3-typeahead/4.0.1/bootstrap3-typeahead.min.js"></script>  
</head>
<body>

<div class="row">
    <div class="col-md-12 text-center">
        <br/>
        <h1>Search Here</h1>    
            <input id="my-input"class="typeahead form-control" style="margin:0px auto;width:300px;" type="text">
    </div>
</div>

<script type="text/javascript">
    // Waiting for the DOM ready...
    $(function(){

      // applied typeahead to the text input box
      $('#my-input').typeahead({
        name: 'countries',

        // data source
        prefetch: 'countries.json',

        // max item numbers list in the dropdown
        limit: 10
      });

    });
  </script>
</body>
</html>

I have given countries name in "countries.json" but the search box doesnt work for me. how to solve this issue ??? ... Is there any problem in the js code.

Mahee ma
  • 11
  • 2
  • is it in the same directory as your html file? Does the console log show it as loaded or do you see any errors in the log? – Ela Buwa Mar 06 '17 at 15:24
  • 1
    Possible Duplicate of http://stackoverflow.com/questions/9232748/twitter-bootstrap-typeahead-ajax-example – Smit Mar 06 '17 at 15:25
  • yes, it is same directory.console doesnt show anything. and i dont see any error. – Mahee ma Mar 06 '17 at 15:26

0 Answers0