Hello i try to get myTasks for the current User from sharepoint 2013. I tried it with the Rest-API and with JSON but i always get an error. Acording to the debugger ExecuteOrDelayUntilScriptLoaded is undefined.
Here is my little Javascript i got so far:
<script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="/_layouts/15/MicrosoftAjax.js"></script>
<script type="text/javascript" src="/_layouts/15/sp.runtime.js"></script>
<script type="text/javascript" src="/_layouts/15/sp.js"></script>
<script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/jquery.ui/1.9.0/jquery-ui.min.js"></script>
<script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/knockout/knockout-2.1.0.js"></script>
<script type="text/javascript" src="/sps10/EDV/jquery.js"></script>
<script type="text/javascript">
var context, userSessionManager ,userSession , query , myTasks ;
$(document).ready(function () {
ExecuteOrDelayUntilScriptLoaded(function () {
context = SP.ClientContext.get_current();
ExecuteOrDelayUntilScriptLoaded(function () {
userSessionManager = new SP.WorkManagement.OM.UserOrderedSessionManager(context);
userSession = userSessionManager.createSession();
query = new SP.WorkManagement.OM.TaskQuery(context);
myTasks = userSession.readTasks(query);
}, "sp.workmanagement.js");
getMyTasks();
}, "sp.js");
});
function getMyTasks() {
context.load(myTasks);
context.executeQueryAsync(onGetMyTasksSuccess, onGetMyTasksFail);
}
// This function is executed if the above call is successful
function onGetMyTasksSuccess() {
console.log("Successfully retrieved tasks...");
var taskEnumerator = myTasks.getEnumerator();
while (taskEnumerator.moveNext()) {
var task = taskEnumerator.current;
console.log("Task: " + task.get_id() + " - " + task.get_name());
}
}
// This function is executed if the above call fails
function onGetMyTasksFail(sender, args) {
console.log('Failed to get tasks. Error:' + args.get_message());
}
</script>
So any help or advise would be great. If you want i can post my Code with the rest-api too but the error stays the same.
Thanks for your help and time.
Here is now the way to query the tasks from my site in a html file with javascript. The most important thing is to load the src file in the right order and to use only the jquery-min file not the normal jQuery file.
<script src="/_layouts/15/init.js" type="text/javascript"></script>
<script src="/_layouts/15/MicrosoftAjax.js" type="text/javascript"></script>
<script src="/_layouts/15/sp.core.js" type="text/javascript"></script>
<script src="/_layouts/15/sp.runtime.js" type="text/javascript"></script>
<script src="/_layouts/15/sp.js" type="text/javascript"></script>
<script src="/_layouts/15/sp.workmanagement.js" type="text/javascript"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.12.4.min.js" type="text/javascript"></script>
<script type="text/javascript">
'use strict';
var context = new SP.ClientContext.get_current();
var userSessionManager = new SP.WorkManagement.OM.UserOrderedSessionManager(context);
var userSession = userSessionManager.createSession();
var query = new SP.WorkManagement.OM.TaskQuery(context);
var myTasks = userSession.readTasks(query);
var tasks = [];
getMyTasks();
function getMyTasks() {
context.load(myTasks);
context.executeQueryAsync(onGetMyTasksSuccess, onGetMyTasksFail);
}
function onGetMyTasksSuccess() {
console.log("Successfully retrieved tasks...");
var taskEnumerator = myTasks.getEnumerator();
while (taskEnumerator.moveNext()) {
var task = taskEnumerator.current;
console.log("Task: " + task.get_id() + " - Taskname: " + task.get_name() + " - Beschreibung: " + task.get_description() + " - dueDatum: " + task.get_dueDate() + " - Startdatum: " + task.get_startDate() + " - Persönlich: " + task.get_isPersonal() + " - Fertiggestellt: " + task.get_isCompleted());
tasks.push({
taskName: task.get_name(),
description: task.get_description(),
dueDate: task.get_dueDate(),
startDate: task.get_startDate(),
personally: task.get_isPersonal(),
complete: task.get_isCompleted()
});
}
console.log(tasks);
}
// This function is executed if the above call fails
function onGetMyTasksFail(sender, args) {
console.log('Failed to get tasks. Error:' + args.get_message());
}
And here is a nice little blog post with all the possibilities:
Related
I'm trying to make application with Spring Boot, Neo4j and jQuery. For that I used Neo4j example project from github, but I'm getting error in those lines:
<script type="text/javascript" src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="https://d3js.org/d3.v3.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
$(function () {
function showMovie(title) {
$.get("/movies/search/findByTitle?title=" + encodeURIComponent(title), // todo fix paramter in SDN
function (data) {
if (!data) return;
var movie = data;
$("#title").text(movie.title);
$("#poster").attr("src","/posters/"+encodeURIComponent(movie.title)+".jpg");
var $list = $("#crew").empty();
movie.roles.forEach(function (cast) {
$.get(cast._links.person.href, function(personData) {
var person = personData.name;
var job = cast.job || "acted";
$list.append($("<li>" + person + " " +job + (job == "acted"?" as " + cast.roles.join(", ") : "") + "</li>"));
});
});
}, "json");
return false;
}
</script>
I'm getting error 404 when trying to use two first scripts. I'm running this project on my local server.
EDIT.
Here is response with an error:
I have a problem please help me,
I have a sound recording page without interface, but I can not know which audio track was recorded,
Is there a way to know the track of a recorded sound or not?
I just want the audio track to play the audio track
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for Cordova to load
document.addEventListener("deviceready", onDeviceReady, false);
// PhoneGap is ready
//
function onDeviceReady() {
recordAudio();
}
// Record audio
//
function recordAudio() {
var srcd = "myrecording" + Math.random() + ".wav";
var mediaRec = new Media(srcd, onSuccess, onError);
// Record audio
mediaRec.startRecord();
// Stop recording after 10 sec
var recTime = 0;
var recInterval = setInterval(function () {
recTime = recTime + 1;
setAudioPosition(recTime + " sec");
if (recTime >= 10) {
clearInterval(recInterval);
mediaRec.stopRecord();
}
}, 1000);
}
function onSuccess() {
alert('Uploaded Successfully');
}
// onError Callback
//
function onError(error) {
alert('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
}
// Set audio position
//
function setAudioPosition(position) {
document.getElementById('audio_position').innerHTML = position;
}
</script>
</head>
<body>
<button onclick="recordAudio()">Record Audio</button>
<p id="media">Recording audio...</p>
<p id="audio_position"></p>
<br>
</body>
</html>
I'm using a lazyload function that works with jQuery.
I'm calling it in my liga.js file like this:
lazyload();
Now, at the footer of that page I have:
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<script src="code.jquery.com/ui/1.12.1/jquery-ui.min.js" ></script>
<script src="/includes/jquery.lazyload.min.js"></script>
<script src="/includes/liga.js"></script>
As you can see my liga.js file is at the very end of the list.
I've also tried calling the function like this:
$(document).ready(function(){
lazyload();
...
I keep getting the error:
ReferenceError: lazyload is not defined
Why is that?
the syntax with the jQuery wrapper is $(selector).lazy() ...
$(function() {
$('.iam').lazy({
/* called before an element gets handled */
beforeLoad: function(element) {
var imageSrc = element.data('src');
console.log('image "' + imageSrc + '" is about to be loaded');
},
/* called after an element was successfully handled */
afterLoad: function(element) {
var imageSrc = element.data('src');
console.log('image "' + imageSrc + '" was loaded successfully');
},
/* called whenever an element could not be handled */
onError: function(element) {
var imageSrc = element.data('src');
console.log('image "' + imageSrc + '" could not be loaded');
},
/* called once all elements were handled */
onFinishedAll: function() {
console.log('finished loading all images');
}
});
});
<script src="//code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery.lazy/1.7.10/jquery.lazy.min.js"></script>
<img class="iam" data-src="http://www.ektoplazm.com/img/escape-into-the-mirror.jpg" width="640" height="640" />
Using socket.io and jQuery how do I send a file (binary array) to my server? This is what I've tried:
<script type="text/javascript" charset="utf-8">
$(document).ready(function () {
var socket = io.connect('http://' + document.domain + ':' + location.port);
$('form#upload_form').submit(function (event) {
//var File fileObj = new File($('#ssa_data').val());
socket.emit('certificate_upload', {transport_key: $('#small_file').val()});
return false;
});
});
</script>
I am working on an Asp.Net MVC application where I am using signalR for real time database notifications
I am trying to create a proxy using the following script
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>JobStatus</title>
#Styles.Render("~/Content/css")
#Scripts.Render("~/bundles/modernizr")
#Scripts.Render("~/bundles/jquery")
<script src="~/Scripts/jquery.signalR-2.0.1.min.js"></script>
<script src="~/signalr/hubs" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
// Proxy created on the fly
var job = $.connection.jobHub;
// Declare a function on the job hub so the server can invoke it
job.client.displayStatus = function () {
getData();
};
// Start the connection
$.connection.hub.start();
getData();
});
function getData() {
var $tbl = $('#tblJobInfo');
$.ajax({
url: '../JobInfo/',
type: 'GET',
datatype: 'json',
success: function (data) {
if (data.length > 0) {
$tbl.empty();
$tbl.append(' <tr><th>ID</th><th>Name</th><th>Last Executed Date</th><th>Status</th></tr>');
var rows = [];
for (var i = 0; i < data.length; i++) {
rows.push(' <tr><td>' + data[i].JobID + '</td><td>' + data[i].Name + '</td><td>' + data[i].LastExecutionDate.toString().substr(0,10) + '</td><td>' + data[i].Status + '</td></tr>');
}
$tbl.append(rows.join(''));
}
}
});
}
</script>
</head>
<body>
<div>
<table id="tblJobInfo" style="text-align:center;margin-left:10px"></table>
</div>
</body>
</html>
my SignalR Hub class is as follows
public class JobHub : Hub
{
public static void Show()
{
IHubContext context = GlobalHost.ConnectionManager.GetHubContext<JobHub>();
context.Clients.All.displayStatus();
}
}
but for some reason when I go to my view on the browser and look at the console it throws me follwing error
TypeError: $.connection is undefined
var job = $.connection.jobHub;
Not sure how to deal with this
Check if:
~/Scripts/jquery.signalR-2.0.1.min.js
is available and loading correctly
You can also reference it from cdn:
http://ajax.aspnetcdn.com/ajax/signalr/jquery.signalr-2.0.1.min.js