I know a lot of people have had issues with Ajax and older versions of Coldfusion, but I'm using Coldfusion 11 Developer on my local machine and am finding it impossible to bind - under all circumstances - using Coldfusion functions, to a CFC, although it's not always the same error that gets returned.
I can't use autosuggest for a cfdiv when that binds to a CFC - but I can bind to autosuggest data on the same page, including from a database. When I bind to a CFC, invariably, the error message in CFDebug comes up as
"error:widget: Bind failed for autosuggest lastname, bind value is not a 1D array of strings. info:http: CFC invocation response: ["Barken","Barnes"] ...
... by which you can see, that the bind IS a 1D array of strings and the CFC produced them, but wouldn't return them to the calling page!
I've also tried making the CFC much simpler, removing the database element and manually creating a straightforward 1D array of strings, but the same error comes up as when fed from my database.
So I made a test even simpler, avoiding databases and arrays to test ordinary, simple binding, not involving autosuggest - just an ordinary bind to a CFC (I always can successfully bind to data on the same page, or a URL.)
Here's the simplest test code, which still doesn't work:
<body>
<cfform id="myForm" name="myForm">
Enter your name into the box:<br />
<cfinput type="text" name="myText">
</cfform>
<hr />
Below is a cfdiv container, with a bind to a CFC:<br />
<cfdiv bind="cfc:bindsource.getDivContent({myText})"></cfdiv>
</body>
This is the CFC, named bindsource.cfc, in the same folder as the form page:
<cfcomponent output="false">
<cffunction name="getDivContent" returntype="string" access="remote" >
<cfargument name="edit">
<cfreturn "Your entered content was: #arguments.edit#">
</cffunction>
</cfcomponent>
In this case, the error I get is: window:global: Uncaught exception: TypeError: Cannot convert '_289[i]' to object (http://localhost:8500/CFIDE/scripts/ajax/package/cfajax.js, line 872) info:http: CFC invocation response: "Your entered content was: William"
(William is the text I entered into the box on the main page. line 872 in the cfajax.js is "872 throw new SyntaxError("parseJSON")"
In this simple test, on my main page, both before and after I enter something into the text input, in the area of what would be the cfdiv, the word "undefined" appears.
Sometimes, if I don't get the 1D array of strings error on some of the test pages, I get this can't convert to object error.
All the examples I've tried - not just my own stuff but all the samples I can find - run, up to the point where the Ajax error kicks in, so there are no other syntax errors. In all cases, the form page loads and runs, the CFC seems to get called, processes as appropriate - CFDebug shows me correct output of the CFC in the debug window - but then nothing ever comes back to the calling page. If I use a url bind, or a same page bind, it does - with a CFC, it doesn't. Ever.
When I test the CFC independently in a direct URL with method and argument passed, it works - I get the same result as the CFC invocation response.
Has anybody EVER got a CFC bind to work in Coldfusion? What am I missing or is CF11 just flawed? The whole things seems a bit unstable. I also get "cannot find CFC" errors, but if I do nothing, switch off, start up again - that particular error doesn't happen again for the same files until sometime later in the session, after repeated attempts to get one of the tests to work.