Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //index.php
- <!DOCTYPE html>
- <html>
- <meta charset="utf-8">
- <head>
- <title>Live Søk</title>
- </head>
- <body>
- <div id="sokher">
- <label for="search">Live Søk</label>
- <p>Skriv inn navn</p>
- <input type='text' id='sok' />
- </div>
- <ul id="results"></ul>
- <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
- <script src="autofill.js"></script>
- </body>
- </html>
- //autofill.js
- $("sok").change(function() {
- // endre resultatan
- }]);
- $.ajax({ url: "navn.json", success: function(liste) {
- $.each(liste, function(k,v) {
- $("#results").append("<li>"+v['navn']+"</li>");
- });
- }, dataType: 'json'
- });
- //navn.json
- [
- {
- "navn":"Kari Norrmann"
- },
- {
- "navn":"Ola Norrmann"
- },
- {
- "navn":"Per Norrmann"
- }
- ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement