I'm having an issue though running the code at the bottom. Using
LiveHTTP headers I get the following:
HTTP/1.x 405 Method Not Allowed
Date: Thu, 15 Jun 2006 19:46:58 GMT
Server: Apache
Allow: GET, HEAD, OPTIONS, TRACE
Keep-Alive: timeout=15, max=10000
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html; charset=iso-8859-1
Here's the test page:
http://www.commadelimited.com/travian/test.html
I'm able to use CFCs and in fact, I'm using them exclusively for this
site. I'm not however calling any of them remotely, which I suppose
could be the issue. This will be the first time I've called a CFC
remotely.
Do you have any ideas as to what could be occurring?
======== begin code block ============
<html>
<head>
<title> new document </title>
<script src="includes/js.js"></script>
<style type="text/css">
<!--
#yourDiv { display: none; }
#myDiv { display: block; }
-->
</style>
<script>
function findzip_request(){
param = 'zip='+document.getElementById('zipcode').value;
http( 'POST' , 'includes/q.cfc?method=findZipCode' , findzip_response
, param );
}
function findzip_response(obj){
document.getElementById('city').innerHTML = obj.city;
document.getElementById('state').innerHTML = obj.state;
document.getElementById('yourDiv').style.display = 'block';
document.getElementById('myDiv').style.display = 'none';
}
</script>
</head>
<body>
<fieldset>
<legend>Enter a U.S. ZipCode and submit.</legend>
<p> <input id="zipcode" type="text">
<input type="button" value="Find Zip"
onclick="findzip_request();"></p>
<p> <label>City:</label> <span id="city"></span></p>
<p> <label>State:</label> <span id="state"></span></p>
</fieldset>
<br><br>
<div id="myDiv">Register now.</div>
<div id="yourDiv">You're logged in, that's great!</div>
</body>
</html>
Here's the function, pretty much unchanged from your example code:
<cffunction name="findZipCode" access="remote" returntype="void">
<cfargument name="zip" type="string" required="Yes"
default="00000">
<cfset result = structNew()>
<cfset result.city = "N/A">
<cfset result.state = "N/A">
<cfset zipURL =
"http://www.webservicex.net//uszip.asmx/GetInfoByZIP">
<cfhttp method="GET" url="#zipURL#?USZip=#arguments.zip#"/>
<cftry>
<cfset addyObj = xmlParse(cfhttp.filecontent)>
<cfset result.city =
trim(addyObj.newDataset.table.city.xmlText)>
<cfset result.state =
trim(addyObj.newDataset.table.state.xmlText)>
<cfcatch><!--- do nothing ---></cfcatch>
</cftry>
<cfwddx action="CFML2JS" input="#result#" toplevelvariable="r">
</cffunction>
======== end code block ============
And you are doing a POST. You can try to run this as a GET and place the
"params" variable in the queryString instead. Or modify the Header. XHR
makes it pretty easy to modify headers but the JSMX abstraction layer (ie..
http() ) may make that a bit more difficult to get to. You can open up
engine.js and modify it if you feel confident in doing so.
I'll look into a way to expose the headers in my next version release.
HTH,
-Todd
I tried changing the CFC based function from this:
param = 'zip='+document.getElementById('zipcode').value;
http( 'POST' , 'includes/jsmx.cfc?method=findZipCode' ,
findzip_response , param );
to this:
param = 'zip='+document.getElementById('zipcode').value;
http( 'GET' , 'includes/jsmx.cfc?method=findZipCode&' + param,
findzip_response , param );
But I'm still getting the same error. I'm sorry about this but I'm not
all that great with javascript.
That's a different CFC but you can see that it actually let's you
download the CFC completely intact. That's got to be the reason this is
happening...I just don't know why.
I feel silly for asking this but, you are running MX and not CF5 aren't you?
Based on the response I got when I called your page, it seems like you might
be running a "pre-MX" version of CF that doesn't support .cfc.
I called the CFC directly via the URL you provided and checked the mime type
that was returned (which was "text/plain") which would indicated the http
server doesn't understand the file extension so it is returning it as plain
text.
Assuming you're running CF5 or earlier, that would make sense. If you are
running MX then perhaps your install was corrupted. Are there CFC's that you
can call successfully on that server?
Check either your ISAPI setting in IIS or the httpd file in Apache and make
sure the .cfc file extension is included. If not, just add it in using the
same settings as .cfm.
Hopefully that helps,
-Todd
-----Original Message-----
From: JS...@googlegroups.com [mailto:JS...@googlegroups.com] On Behalf Of Andy
Matthews
Sent: Thursday, June 15, 2006 6:55 PM
To: JSMX
It appears that there's some sort of proxy stuff going on with our
server cluster. Our system is passing requests for CFM pages through to
an alternate server, but not for CFC pages. Since I'm the only one in
our company using CFCs this apparently got overlooked. They're making
the update now and hopefully (crosses ffingers) it'll be fixed when the
servers get restarted.
Thanks for all of your help.