GithubHelp home page GithubHelp logo

global variable about sharepointplus HOT 4 CLOSED

aymkdn avatar aymkdn commented on June 1, 2024
global variable

from sharepointplus.

Comments (4)

Aymkdn avatar Aymkdn commented on June 1, 2024

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.

bsound83 avatar bsound83 commented on June 1, 2024

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.

Aymkdn avatar Aymkdn commented on June 1, 2024

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.

bsound83 avatar bsound83 commented on June 1, 2024

Yes it does...thanks for the reference. This has enlighten how ajax is utilized.

from sharepointplus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.