javascript - Calling the Web API with jQuery -
i have following errors:
i able search .json
file name search same time id well. went through jquery traversing methods w3schools not find answer looking for.
my second problem have used jquery autocomplete plugin, not seems working on content. missing? , should focus on?
here code:
<!doctype html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>kunde</title> <script src="autocomplete/jquery.easy-autocomplete.min.js"></script> <link href="autocomplete/easy-autocomplete.min.css" rel="stylesheet" /> <script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-2.0.3.min.js"></script> <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <link href="custom.css" rel="stylesheet" /> </head> <body> <div class="container"> <div class="jumbotron"> <h2>toolbox search</h2> <h3>search id or name </h3> <input type="text" id="kunde" size="50" /> <input type="button" value="search" onclick="find();" /> </div> <ul></ul> <div class="footer"><p> © copyright 2016</p> <strong><a href="http://rackpeople.com/">rackpeople</a></strong>.</div> </div> <script> var uri = 'json.json'; function find() { var info = $('#kunde').val(); $.getjson(uri).done(function (data) { var item = data.filter(function (obj) { return obj.name === info; })[0]; if (typeof item !== 'undefined' || item !== null) { $("ul").append("<li>" + 'id = ' + item.id, 'name = ' + item.name, "<br />" + 'phone = ' + item.phone, "<br />" + 'contact = ' + item.contact, "<br />" + 'balancelcy = ' + item.balancelcy, "<br />" + 'creditlimitlcy = ' + item.creditlimitlcy, "</li>") } }).fail(function (jqxhr, textstatus, err) { $('#results').text('error: ' + err); }); } var options = { url: "json.json", getvalue: "name", list: { match: { enabled: true } }, theme: "square" }; $("#kunde").easyautocomplete(options); </script> </body> </html>
Comments
Post a Comment