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() {
    url: "http://chnsharepoint02/PWA" + "/_api/ProjectServer/Projects",
    method: "GET",
    headers: { "Accept": "application/json; odata=verbose" },
    success: function (data) {
    error: function (data) {
  • 1
    Try adding async:false to $.ajax() parameters to force execution.
    – Akhoy
    Jul 17 '15 at 13:21
  • perfect, that was stupid of me. Please add this as an answer, will mark it.
    – Rohit
    Jul 17 '15 at 13:35
  • Added. Glad it helped. :)
    – Akhoy
    Jul 17 '15 at 13:38

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.