Sorry if this is a duplicate post, but not sure my original posting on
the topic actually went. [Don't see it on the group list]

On Mac Os X with Apache personal web server.
Maybe someone else can try this.
1). Cut and paste the HTML to some place (like your DocumentRoot).
2). Be mindful of the reference to location for MochiKit.js in the HTML
below
3). The utility JavaScript (Chapter15.js) can co-reside in the same
folder as the HTML, as can the Python CGI script (at least I think it
can; doesn't seem to make a difference)

The test HTML looks like this:

Foo.html -------------------------------------

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
<html>
   <head>
       <title>Demo Tag Cloud Model</title>
      <script type="text/javascript"
src="../../../scripts/MochiKit/MochiKit.js"></script>
       <script type="text/javascript" src="Chapter15.js" ></script>
   </head>
   <body>
       <h1>Tag Test</h1>
       <form name="Enter Stuff">
           <label>Enter something:</label>
           <input id="blah" name="user" value="lucid"/>
       </form>
       <a href="javascript:void(0)" onclick="DBQuery()">Click Me</a>
       <div id="HERE"/>
   </body>
</html>


---------------------------------------------------------------------

calls this Javascript:
Chapter15.js --------------------------------------------

var xmlHttpReq = false;
var gotMetadata = function (oData) {
   log("gotMetadata"+oData.responseText);
   var payload = evalJSONRequest( oData);
   replaceChildNodes( "HERE", P( null, payload.what));
};

var metadataFetchFailed = function (err) {
 alert( "The metadata for MochiKit.Async could not be fetched :"+err);
};

function DBQuery() {
   xmlHttpReq = getXMLHttpRequest()
   log("got xmlHttpReq ");
   xmlHttpReq.open( "POST", "Chapter15.py", true); // doesn't work
   //xmlHttpReq.open( "GET", "Chapter15.py", true); //
   log("got xmlHttpReq.open OK ");
   xmlHttpReq.setRequestHeader('Content-Type',
'application/x-www-form-urlencoded');
   log("got xmlHttpReq.setRequestHeader OK ");
   var d = sendXMLHttpRequest( xmlHttpReq, "blah=" +
escape(getElement( "blah").value));
   d.addCallbacks(gotMetadata, metadataFetchFailed);
   log("got xmlHttpReq.sendXMLHttpRequest OK ");
}

---------------------------------------------------------------------


Which in turn invokes this python cgi script:
Chapter15.py-------------------------------------------


#!/usr/local/bin/python

import cgi

form = cgi.FieldStorage()
stuff = form.getfirst( "blah", "")


print """
{ "what": " %s" }
""" % stuff

---------------------------------------------------------------------
If I try a POST in Chapter15.js, then I get this series of log
messages:
INFO: got xmlHttpReq
INFO: got xmlHttpReq.open OK
INFO: got xmlHttpReq.setRequestHeader OK
INFO: got xmlHttpReq.sendXMLHttpRequest OK
INFO: The metadata for MochiKit.Async could not be fetched
:MochiKit.Async.XMLHttpRequestError("Request failed")

If I try a GET , then the log traces show:
INFO: got xmlHttpReq
INFO: got xmlHttpReq.open OK
INFO: got xmlHttpReq.setRequestHeader OK
INFO: got xmlHttpReq.sendXMLHttpRequest OK
INFO: gotMetadata ... has the content of Chapter15.py as the
oData.responseText, and hence nothing that looks like JSON for the
replaceChildNodes to work with

This may not be a  MochiKit problem at all, but rather an Apache config
problem, nonetheless I thought I would ask for a little crowd wisdom

Thanks in advance for any clues!


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