testing the new Promises Alpha (=4)

Mar 11, 2013 at 2:12 PM
This routine does what it is supposed to do but never executes the .done clause
    function setUpdated(idRec) {
        var updatePromise = $().SPServices({
            operation: "UpdateListItems",
            batchCmd: "Update",
            listName: "{D3795486-9926-424E-8F14-59BE5DB65BA8}", 
            ID: idRec,
            valuepairs: [["Exported", 1]]
        }); //SPServices
        //notify when done
        updatePromise.done(function() {alert("we're done");});
        updatePromise.fail(function() {alert("we failed");});
    }
Coordinator
Mar 12, 2013 at 2:22 PM
Michael:

Sorry for the delay in getting back to you.

I just tried the following code with ALPHA4 and ALPHA5 (which I'm still working on) in both IE9 and Firefox. In all cases, the "we're done" alert popped up. Can you give some more context for what you are doing? Or maybe isolate it down a bit?

M.
$(document).ready(function() {

    var updatePromise = $().SPServices({
        operation: "UpdateListItems",
        batchCmd: "Update",
        listName: "States", 
        ID: 267,
        valuepairs: [["State_x0020_Abbreviation", "BL"]]
    }); //SPServices

    //notify when done
    updatePromise.done(function() {alert("we're done");});
    updatePromise.fail(function() {alert("we failed");});

});
Mar 12, 2013 at 2:56 PM
Thanks for testing that piece of code. I suspected it might be something like browser version. That code is part of an SP2007 project, where we're only allowed to use IE7. IE didn't get ECMA5 JavaScript until version 9, but I wasn't sure whether you were using the browser JavaScript or jQuery for your Promises. That's why I did the second sample, which succeeds using jQuery (not published; uses Deferred() and explicitly resolves/rejects the object). As long as I know that the requirement is IE9+, I'm fine. Thanks...
Coordinator
Mar 12, 2013 at 3:06 PM
jQuery is generating the promises. I haven't tried testing in IE7, but my dev environment for SPServices is WSS 3.0. I would expect things to work in IE8 for sure, and probably IE7.

M.
Mar 12, 2013 at 6:27 PM
I stripped the code down to just that routine, and it works fine under MOSS/IE7. There's obviously something else going on in the full version of my code.
Coordinator
Mar 13, 2013 at 1:43 PM
Good for me, I guess, but not so good for you. Let me know if you need help.

M.
Coordinator
Mar 13, 2013 at 1:44 PM
BTW, I signed up for spoon.net yesterday, so I can test things easily in IE7 now.

M.
Mar 13, 2013 at 5:26 PM
I have now translated all code in that program to Promises and it runs "perfectly." By 'perfectly'--a relative word--I mean that it runs exactly like the previous pre-Promises code. Unfortunately, the problem I was hoping to address did not disappear with the change to Promises. Its source does, however, become clear.

Looking forward to great things with Promises. Thanks for much for taking the plunge...
Coordinator
Mar 13, 2013 at 5:44 PM
One thing you should see is that the calls to the Web Services don't lock up the page the way synchronous calls do.

You're an early adopter - I'd love to hear how it goes as you are implementing promises.

M.