I am trying to figure out how to make an ajax call in a module and I am not even sure where to begin. If I am in a module can I even use the coldbox proxy or is that out the window? I don’t think you would want the user to have to configure that in the parent application.
So I made a function in my users handler and if you go to the url below in a browser window you can hit it.
/**
@returnformat json
*/
remote string function usernameExists(event){
var rc = event.getCollection();
var user = userService.findWhere({username=rc.username});
return !isNull(user);
}
I personally still run my requests through a coldbox proxy object even in modules.
<cfcomponent name="SomeProxy" output="false" extends="coldbox.system.remote.ColdboxProxy" hint="Proxy to tie our ajax calls to coldbox">
Ok, I don’t use ColdboxProxy. I think this is more for those who are doing Flash and that type calls, I prefer to use a normal controller/handler for all my Ajax calls.
So what I am saying is that instead of calling it through the proxy like you are trying, just do a normal event handler call through you Ajax URL call.
And if you use the RESTFul features in the handler you can lock it down to just a get call, etc.
I was trying to return the data right from the method which was causing the layout to load and in turn debugging was loading so the xhr call was messed up…
here is my handler method (don’t get caught up on the result, I was just playing around here…
public void function usernameExists(event) {
var rc = event.getCollection();
var user = userService.findWhere({username=rc.username});
var result = {};
Yes, that is what I was going to write. Leverage renderData() to return marshalled data and just use your normal ses handling for this. I personally don’t use the proxy unless I am doing Air or Flex or cfc data binding.
Luis F. Majano
President
Ortus Solutions, Corp