Comments (4)
Hi,
Actually, the requests are asynchronous. So it means you cannot return a value. You need to think differently. For example :
var value="";
$SP().list("list").get(function(data) {
if (data.length===1) value = data[0].getAttribute("Title");
getValue()
});
function getValue() {
console.log(value);
}
from sharepointplus.
I see...is there a way to control the asynchronous option similar to $SPServices? I've been using $SPServices prior which has a way to send request where async : false. I am enjoying your library because of the low overhead of making list requests in addition to other benefits. I will approach this particular item differently and wrap my events inside the SP+ call.
I've noticed in other posts that you reference $SPServices, do you typically use $SharepointPlus and $SPServices together?
Thanks for the prompt response!
from sharepointplus.
Previously I had the synchronous option, but then it makes no sense to keep it, because it's a very bad way to program (the HTTP requests are asynchronous, and it's dangerous to have them synchronous because all your program will freeze until the request is completed).
So I really recommand you to think differently your code!
You can change this behavior using $.ajaxSetup()
from jQuery (set 'async' to false). But read what they said on their website:
The first letter in Ajax stands for "asynchronous," meaning that the operation occurs in parallel and the order of
completion is not guaranteed. The async option to $.ajax() defaults to true, indicating that code execution can
continue after the request is made. Setting this option to false (and thus making the call no longer asynchronous)
is strongly discouraged, as it can cause the browser to become unresponsive.
Regarding your question: yes you can use SPService and SharepointPlus all together. That can be useful if something is available in SPService but not in SharepointPlus.
I hope it helps.
from sharepointplus.
Yes it does...thanks for the reference. This has enlighten how ajax is utilized.
from sharepointplus.
Related Issues (20)
- getWorkflowID does not work in NodeJS HOT 6
- stopWorkflow does not work inside NodeJS : ReferenceError: document is not defined HOT 16
- $SP().getUserInfo POST Status 500 error HOT 2
- .get() paging and rowlimit not working for SPO document library HOT 7
- need an example for add.options.packetsize HOT 6
- setReadOnly:Error HOT 3
- Observables with Sharepoint+ HOT 1
- Getting the count of rows from a list HOT 2
- Error from server-side node HOT 4
- addAttachment contextinfo 404 error HOT 19
- Get Column Type HOT 1
- Translate SharePoint column names HOT 2
- distribution list members HOT 2
- Unable to getContentTypeInfo HOT 3
- The site URL passed in the setup object is always ignored in the isMember(...) function HOT 6
- RequestError: Error: tunneling socket could not be established, cause=Client network socket disconnected before secure TLS connection was established HOT 1
- sp.lists gives `ReferenceError: window is not defined` HOT 2
- sharepointplus with sp-rest-proxy HOT 11
- incorrect hasREST function behavior for Sharepoint Online / 365 HOT 2
- joins HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sharepointplus.