mardi 2 décembre 2014

Uncaught ReferenceError: $ is not defined Page.aspx



I want to READ list data from with the help of RESTAPI in SharePoint. I use below code to do the operation.



<script src="http://ift.tt/1dW8QIk"></script>
<script type="text/javascript">

function getListItemById(webUrl,listName, itemId, success, failure) {
var url = webUrl + "/_vti_bin/listdata.svc/" + listName + "(" + itemId + ")";
$.ajax({
url: url,
method: "GET",
headers: { "Accept": "application/json; odata=verbose" },
success: function (data) {
success(data.d);
alert('Success');
},
error: function (data) {
failure(data.responseJSON.error);
}
});
}


//Usage
getListItemById('http://ctv-test', 'RESTList', 2, function (taskItem) {
console.log(taskItem.TaskName);
},
function(error){
console.log(JSON.stringify(error));
}
);
</script>


When I execute my code I get below 2 errors in browser console.



Uncaught ReferenceError: $ is not defined Page.aspx


Uncaught TypeError: Cannot read property 'parentElement' of null









0 commentaires:

Enregistrer un commentaire