I try to run the below javascript code but it does not work. (it does not return the alert pop up) I put the url string into a browser, it return the item info. So, I assume the url is fine. And the server return the information I want.
URL to brower:
/_api/web/lists/getbytitle('<Listname>')/items(1)/AttachmentFiles/
Returns:
<?xml version="1.0" encoding="utf-8"?><feed xml:base="myurl/_api/"; xmlns="w3.org/2005/Atom"; xmlns:d="schemas.microsoft.com/ado/2007/08/dataservices"; xmlns:m="schemas.microsoft.com/ado/2007/08/dataservices/metadata"; xmlns:georss="georss.org/georss"; xmlns:gml="opengis.net/gml">
<content type="application/xml">
<m:properties>
<d:FileName>attached_filename.csv</d:FileName>
<d:ServerRelativeUrl>/DART/Lists/test/Attachments/1/attached_filename.csv</d:ServerRelativeUrl>
</m:properties>
</content>
</entry></feed>
But why the code stop here? What is wrong? in the code? in the server? Any help is appreciated. Thank you so much!
$.ajax({
type: "GET",
url: url + "/_api/web/lists/getbytitle('" + name + "')/items(" + id + ")/AttachmentFiles/",
headers: {
"accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose"
},
success: function(data) { alert('succ');},
error: function() {alert('err');}
});
I am including the following before the script:
<script type="text\javascript" src="code.jquery.com/jquery-1.11.3.min.js">; </script>
After I looked into the error info, I found the $ is underfined error. Any idea why? How can I defined $? Thanks! SCRIPT5009: '$' is undefined it is near the ajax.