Monday, November 16, 2009

Get list items using JQuery and SPServices

<html
xmlns="http://www.w3.org/1999/xhtml"
>
<
head
runat="server">


<
title></title>

<
script
src="jquery.min.js"
type="text/javascript"></script>
<
script
src="jquery.SPServices.min.js"
type="text/javascript"></script>
<
script
src="print_r.js"
type="text/javascript"></script>

<
script
type="text/javascript">


$(document).ready(function() {

waitMessage = "<table width='100%' align='center'><tr><td align='center'>a</td></tr></table>";

$("#WSOutput").html(waitMessage).SPServices(

operation: "GetListItems",
webURL: "http://yoursite",
listName: "Training Programmes",
CAMLViewFields: "<ViewFields><FieldRef Name='Course_x0020_Name'/>\
<FieldRef Name='Course_x0020_Outline'/>\
<FieldRef Name='Code'/><FieldRef Name='Attachments'/></ViewFields>"
,
CAMLQuery: "<Query></Query>",
CAMLRowLimit: 10000,
CAMLQueryOptions: "<QueryOptions><IncludeAttachmentUrls>TRUE</IncludeAttachmentUrls></QueryOptions>",
completefunc: function(xData, Status) {


$("#WSOutput").html("").append("<b>This is the output from the GetListItems operation:</b>");
$(xData.responseXML).find("z\\:row").each(function() {

$("#WSOutput").append("<li>" + $(this).attr("ows_Course_x0020_Name") +
" " + $(this).attr("ows_Course_x0020_Outline") + " " +
$(this).attr("ows_Code") + " " + $(this).attr("ows_Attachments") + "</li>");

});

$("#WSOutput").append(replaceTags(xData.responseXML.xml));

}

});

});

</script>
</
head>
<
body
>
<
div
id="WSOutput"></div>
<
hr/>
<
div
id="debugDiv1"
style="height:60%;width:50%;overflow-y:auto; overflow-x:hidden" />
</
body>

No comments:

Post a Comment