i have a site collection named 'practice'.in which i have created a document library named 'doclib1'.i have created another document library called 'doclib2'.i want to copy the items( text,pdf,images) of doclib1 to doclib2 using jquery or javascript or REST.plz help and provide the complete code.
i have applied code below:
i got error as- "$ is not defined at copyItem" and "$ is not defined at HTMLinputElement.onclick"
is my code is right?
<!DOCTYPE html><head>
<script type="text/javascript" src="sites/Practice/Shared%20Documents/jquery-3.1.0.min.js"></script>
<script type="text/javascript">
function copyItem(){
var itemurl = "/sites/Practice/docLib1";
var dst = "/sites/Practice/copySubsite1/docLib2";
$().SPServices({
operation: "GetItem",
Url: itemurl,
async: false,
completefunc: function (xData, Status) {
itemstream = $(xData.responseXML).find("Stream").text();
console.log(itemstream);
itemfields = "";
$(xData.responseXML).find("FieldInformation").each(function(){
itemfields+=$(this).get(0).xml;
});
}
});
$().SPServices({
operation: "CopyIntoItems",
SourceUrl: itemurl,
async: false,
DestinationUrls: [dst],
Stream: itemstream,
Fields:itemfields,
completefunc: function (xData, Status) {
var error = $(xData.responseXML).find("CopyResult").first().attr("ErrorCode");
console.log(error);
}
});
}
</script>
</head>
<body>
<input type="button" onclick="copyItem()" value="Copy">
</body>
</html