function loadData() { $("#results").empty(); $.get("FeedServer.ashx?url=http://whoismyrepresentative.com/getall_xml.php?zip=" + $("#txtZipCode").val(), function(data) { $(data).find("rep").each(function() { var html = "<div style=\"margin-top:10px;\">"; html += "<h3>" + $(this).attr("name") + "</h3><table>"; html += "<tr><td style=\"width:150px;\">District:</td><td>"; html += $(this).attr("district") + "</td></tr>"; html += "<tr><td>Office:</td><td>" + $(this).attr("office") + "</td></tr>"; html += "<tr><td>Phone:</td><td>" + $(this).attr("phone") + "</td></tr>"; html += "<tr><td>Party:</td><td>" + $(this).attr("party") + "</td></tr>"; html += "<tr><td>Website:</td><td><a href=\"" + $(this).attr("link"); html += "\" target=\"_blank\">" + $(this).attr("link") + "</a></td></tr>"; html += "</div>"; $('#results').append(html); }); $(data).find("sen").each(function() { var html = "<div style=\"margin-top:10px;\">"; html += "<h3>" + $(this).attr("name") + "</h3><table>"; html += "<tr><td style=\"width:150px;\">Office:</td><td>" + $(this).attr("office"); html += "</td></tr>"; html += "<tr><td>Phone:</td><td>" + $(this).attr("phone") + "</td></tr>"; html += "<tr><td>Party:</td><td>" + $(this).attr("party") + "</td></tr>"; html += "<tr><td>Contact:</td><td><a href=\"" + $(this).attr("contact"); html += "\" target=\"_blank\">" + $(this).attr("contact") + "</a></td></tr>"; html += "<tr><td>Website:</td><td><a href=\"" + $(this).attr("web"); html += "\" target=\"_blank\">"; html += $(this).attr("web") + "</a></td></tr>"; html += "</div>"; $('#results').append(html); }); }); }
<%@ WebHandler Language="C#" Class="FeedServer" %> using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.Services; using System.Xml.Linq; public class FeedServer : IHttpHandler { public void ProcessRequest (HttpContext context) { string url = context.Request.QueryString["url"]; XDocument feedXML = XDocument.Load(url); context.Response.ContentType = "text/xml"; context.Response.Write(feedXML.ToString()); } }