Get Data From a SharePoint list using JQuery
<%@ Page Language="C#" %>
<html dir="ltr">
<head runat="server">
<META name="WebPartPageExpansion" content="full">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled 1</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<input type="button" value="button" onclick="test()"/>
<input type="text" id="output"/>
</div>
</form>
<script language="javascript" type="text/javascript" src=
"/_LAYOUTS/JQuery/jquery-1.3.2.min.js">
</script>
<script language="javascript" type="text/javascript" src=
"/_LAYOUTS/JQuery/jquery.SPServices-0.5.4.min.js">
</script>
<script language="javascript" type="text/javascript" src=
"/_LAYOUTS/JQuery/SPAPI_Lists.js">
</script>
<script language="javascript" type="text/javascript" src=
"/_LAYOUTS/JQuery/SPAPI_Core.js">
</script><script type="text/javascript" language="javascript">
function test()
{
// Return all items in the default view of MyList
var lists = new SPAPI_Lists('http://Test:1659/TestSite');
var items = lists.getListItems('Origin');
if (items.status == 200)
{
var rows = items.responseXML.getElementsByTagName('z:row');
$(items.responseXML).find("z\\:row").each(function()
{
var liHtml = $(this).attr("ows_First_x0020_Name") ;
alert(liHtml);
});
}
else
{
alert('There was an error: ' + items.statusText);
}
}
</script>
</body>
</html>
No comments:
Post a Comment