Hi,

I am starting to get productive using MochiKit, but I cannot quite get
the grip of chained Deferreds.

I have a postJSONDoc function that I got from this group
(http://groups.google.com/group/mochikit/msg/dd23d8779dce92f3?dmode=source)
that looks like this:

postJSONDoc = function (url, postVars) {
        var req = getXMLHttpRequest();
        req.open("POST", url, true);
        req.setRequestHeader("Content-type",
"application/x-www-form-urlencoded");
        var data = queryString(postVars);
        var d = sendXMLHttpRequest(req, data);
        return d.addCallback(evalJSONRequest);
}

This function is called from my code whenever I need to perform a POST.

Now, my problem is that I need to examine the response before I return
it.
If the message equals a special error message from the server, I need
to take special actions before returning the response, so I thought
that chained Deferreds might be a solution.

However, all my attempts to do so have failed.
Does anyone have any suggestions?

Thanks,
Kristoffer

X-Google-Language: ENGLISH,ASCII-7-bit
Received: by 10.11.53.63 with SMTP id b63mr125038cwa;
        Mon, 22 May 2006 07:38:21 -0700 (PDT)
X-Google-Token: wBCdMQwAAADtl4TRErGVdVpF8b6eNGqK
Received: from 85.225.253.207 by j55g2000cwa.googlegroups.com with HTTP;
        Mon, 22 May 2006 14:38:20 +0000 (UTC)
From: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
To: "MochiKit" <[email protected]>
Subject: Chained Deferreds
Date: Mon, 22 May 2006 14:38:20 -0000
Message-ID: <[EMAIL PROTECTED]>
User-Agent: G2/0.2
X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.3) 
Gecko/20060510 Firefox/1.5.0.3,gzip(gfe),gzip(gfe)
Mime-Version: 1.0
Content-Type: text/plain

Hi,

I am starting to get productive using MochiKit, but I cannot quite get
the grip of chained Deferreds.

I have a postJSONDoc function that I got from this group
(http://groups.google.com/group/mochikit/msg/dd23d8779dce92f3?dmode=source)
that looks like this:

postJSONDoc = function (url, postVars) {
        var req = getXMLHttpRequest();
        req.open("POST", url, true);
        req.setRequestHeader("Content-type",
"application/x-www-form-urlencoded");
        var data = queryString(postVars);
        var d = sendXMLHttpRequest(req, data);
        return d.addCallback(evalJSONRequest);
}

This function is called from my code whenever I need to perform a POST.

Now, my problem is that I need to examine the response before I return
it.
If the message equals a special error message from the server, I need
to take special actions before returning the response, so I thought
that chained Deferreds might be a solution.

However, all my attempts to do so have failed.
Does anyone have any suggestions?

Thanks,
Kristoffer


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~----------~----~----~----~------~----~------~--~---

Reply via email to