How to Get Data From Wikipedia Using API and jQuery in C#
.Aspx File
Live Demo
.Aspx File
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="WikirRference.aspx.vb" Inherits="Default2" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <script src="https://googledrive.com/host/0Bw4NrxH2nTVqMnliTHpSY0U4ZE0" type="text/javascript"></script> <script src="https://googledrive.com/host/0Bw4NrxH2nTVqYndKU2p0Z2s3M1E" type="text/javascript"></script> <script src="https://googledrive.com/host/0Bw4NrxH2nTVqX3VZazJtMmxSNW8" type="text/javascript"></script> <title></title> <script type="text/javascript"> $(document).ready(function () { }); function searchdata() { var q = $("#searchterm").val(); $.getJSON("http://en.wikipedia.org/w/api.php?callback=?", { srsearch: q, action: "query", list: "search", format: "json" }, function (data) { $("#results").empty(); $("#results").append("Results for <b>" + q + "</b> </br>"); $("#results").append("<div> </div>"); $.each(data.query.search, function (i, item) { $("#results").append("<div><a href='http://en.wikipedia.org/wiki/" + encodeURIComponent(item.title) + "'>" + item.title + "</a> : " + item.snippet + "</div>"); }); }); } </script> </head> <body> <form id="form1" runat="server"> <div style="border: 2px solid #a1a1a1; padding: 10px 40px; background: #dddddd; width: 300px; border-radius: 25px; height: 60px; text-align: left;"> <b>Wikipedia API Search Using jQuery By http://fantasyaspnet.blogspot.in/</b><br /> (This Wikipedia API will give the search results and references more than one.) </div> <div style="padding-left: 75px; padding-top: 15px;"> <input id="searchterm" type="text" /> <input id="search" type="button" value="Search" onclick="searchdata();" /> </div> <div> </div> <div id="results" style="width: 300px; box-shadow: 10px 10px 5px #888888;"> </div> </form> </body> </html> |
Live Demo
|
No comments:
Post a Comment