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:



<?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">

But why the code stop here? What is wrong? in the code? in the server? Any help is appreciated. Thank you so much!

    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.


1 Answer 1


Remove the semi-colon from your jquery definition tag. It should look something like:

<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>

Text between tags that should reference external scripts will mess things up.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.