1

I have written below code to fetch all the projects, however its not working after $.ajax call. However, strange thing is, if I put a debugger in developer toolbar and debug it for long time (including jquery file) before hitting F5, it works fine and brings all project names. Below is the code.

I replaced project server url with sharepoint list REST call and it works fine.

function getProjects() {
$.ajax({
    url: "http://chnsharepoint02/PWA" + "/_api/ProjectServer/Projects",
    method: "GET",
    headers: { "Accept": "application/json; odata=verbose" },
    success: function (data) {
        success(data);
    },
    error: function (data) {
        failure(data);
    }
});}
3
  • 1
    Try adding async:false to $.ajax() parameters to force execution. Commented Jul 17, 2015 at 13:21
  • perfect, that was stupid of me. Please add this as an answer, will mark it. Commented Jul 17, 2015 at 13:35
  • Added. Glad it helped. :) Commented Jul 17, 2015 at 13:38

1 Answer 1

0

Add async:false to $.ajax() parameters to force execution.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.