$().SPServices({
operation: "GetListItems",
async: false,
listName: "listname",
completefunc: function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function() {
$().SPServices({
operation:'GetAttachmentCollection',
listName: "listname",
ID: $(this).attr("ows_ID"),
completefunc: function (xData, Status) {
$(xData.responseXML).find("Attachments").each(function() {
alert($(this).text());
});
}
});
});
}
});
But theres a much more better way to do it,Thanks to Marc:
var p = $().SPServices({
operation: "GetListItems",
listName: "listname",
CAMLQueryOptions: "<QueryOptions>" +
"<IncludeAttachmentUrls>TRUE</IncludeAttachmentUrls>" +
"</QueryOptions>"
});
p.done(function() {
$(p.responseXML).).SPFilterNode("z:row").each(function() {
var attachments = [];
var att = $(this).attr("ows_Attachments");
if(att !== "0") {
attachments = att.split(";#"); // Now you'll have an array of attachment URLs
} else {
// att will be "0", indicating that there are no attachments
}
});
});
operation: "GetListItems",
async: false,
listName: "listname",
completefunc: function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function() {
$().SPServices({
operation:'GetAttachmentCollection',
listName: "listname",
ID: $(this).attr("ows_ID"),
completefunc: function (xData, Status) {
$(xData.responseXML).find("Attachments").each(function() {
alert($(this).text());
});
}
});
});
}
});
But theres a much more better way to do it,Thanks to Marc:
var p = $().SPServices({
operation: "GetListItems",
listName: "listname",
CAMLQueryOptions: "<QueryOptions>" +
"<IncludeAttachmentUrls>TRUE</IncludeAttachmentUrls>" +
"</QueryOptions>"
});
p.done(function() {
$(p.responseXML).).SPFilterNode("z:row").each(function() {
var attachments = [];
var att = $(this).attr("ows_Attachments");
if(att !== "0") {
attachments = att.split(";#"); // Now you'll have an array of attachment URLs
} else {
// att will be "0", indicating that there are no attachments
}
});
});
No comments:
Post a Comment