Hello,

everyday my admiration of mochikit grows. While "rewriting" my Ajax
applications to use MochiKit, I often need to transfer data to the
server. Asynchronus and all, of course.

There is the possibility to encode it within the request-URI, and that
works fine if I want to have additional information.

BUT I also have to send back user input. Data, that is supposed to
change "something" on the server side. I tend to do this via POST,
because GET is not supposed to change anything on the server.

For this I created
function sendwert(name,wert)
{
    var sendtext="<xml><n>"+name+"</n><w>"+wert+"</w></xml>";
    var xmlhttp=getXMLHttpRequest();
    xmlhttp.open("POST", "/xmeintrag", true);
    xmlhttp.setRequestHeader("Content-Type", "application/xml;
charset=UTF-8");
    var d=sendXMLHttpRequest(xmlhttp, sendtext);
    d.addCallback(function(req)
        {
            var text=req.responseText;
            if (text.substr(0,6)=='FEHLER')
            {
                $("feedback").innerHTML="!!!! FEHLER BEIM SPEICHERN
!!!!";
                alert(text);
                panik(text);
            }
            else
            {
                $("feedback").innerHTML=text;
                callLater(0.5,fade,'feedback',100);
            }
            });

}

and similar with JSON instead of homebrown fake XML.

Now I am wondering: why isn't this kind of "POST" Request within
MochiKit.ASYNC?

I propse to add something along:
function postxmlhttp(uri,obj)
{
    var xmlhttp=getXMLHttpRequest();
    xmlhttp.open("POST", uri, true);
    xmlhttp.setRequestHeader("Content-Type", "application/xml;
charset=UTF-8");
    var d=sendXMLHttpRequest(xmlhttp, serializeJSON(obj));
    return d;
}

to the standard, as "other part" of "loadJSONDoc".

Thanks again for Mochikit!

Harald

PS: europython 2006 in CERN - early bird ends on friday this week. make
sure you are registerd, to learn Web 2.5 at the place Web 0.1 was
invented!

X-Google-Language: ENGLISH,ASCII-7-bit
Received: by 10.11.88.14 with SMTP id l14mr40494cwb;
        Mon, 22 May 2006 06:08:39 -0700 (PDT)
X-Google-Token: XvsGKAwAAAA4iLjrB6XRu2pg11wpymQ2
Received: from 84.57.199.61 by g10g2000cwb.googlegroups.com with HTTP;
        Mon, 22 May 2006 13:08:39 +0000 (UTC)
From: "GHUM" <[EMAIL PROTECTED]>
To: "MochiKit" <[email protected]>
Subject: transfer data to server via POST Request
Date: Mon, 22 May 2006 06:08:39 -0700
Message-ID: <[EMAIL PROTECTED]>
User-Agent: G2/0.2
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.0.3) 
Gecko/20060426 Firefox/1.5.0.3,gzip(gfe),gzip(gfe)
Mime-Version: 1.0
Content-Type: text/plain

Hello,

everyday my admiration of mochikit grows. While "rewriting" my Ajax
applications to use MochiKit, I often need to transfer data to the
server. Asynchronus and all, of course.

There is the possibility to encode it within the request-URI, and that
works fine if I want to have additional information.

BUT I also have to send back user input. Data, that is supposed to
change "something" on the server side. I tend to do this via POST,
because GET is not supposed to change anything on the server.

For this I created
function sendwert(name,wert)
{
    var sendtext="<xml><n>"+name+"</n><w>"+wert+"</w></xml>";
    var xmlhttp=getXMLHttpRequest();
    xmlhttp.open("POST", "/xmeintrag", true);
    xmlhttp.setRequestHeader("Content-Type", "application/xml;
charset=UTF-8");
    var d=sendXMLHttpRequest(xmlhttp, sendtext);
    d.addCallback(function(req)
        {
            var text=req.responseText;
            if (text.substr(0,6)=='FEHLER')
            {
                $("feedback").innerHTML="!!!! FEHLER BEIM SPEICHERN
!!!!";
                alert(text);
                panik(text);
            }
            else
            {
                $("feedback").innerHTML=text;
                callLater(0.5,fade,'feedback',100);
            }
            });

}

and similar with JSON instead of homebrown fake XML.

Now I am wondering: why isn't this kind of "POST" Request within
MochiKit.ASYNC?

I propse to add something along:
function postxmlhttp(uri,obj)
{
    var xmlhttp=getXMLHttpRequest();
    xmlhttp.open("POST", uri, true);
    xmlhttp.setRequestHeader("Content-Type", "application/xml;
charset=UTF-8");
    var d=sendXMLHttpRequest(xmlhttp, serializeJSON(obj));
    return d;
}

to the standard, as "other part" of "loadJSONDoc".

Thanks again for Mochikit!

Harald

PS: europython 2006 in CERN - early bird ends on friday this week. make
sure you are registerd, to learn Web 2.5 at the place Web 0.1 was
invented!


--~--~---------~--~----~------------~-------~--~----~
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