How to suppress view rendering of a default view for ajax calls

I’m trying to use coldbox for an Ajax call but it always includes the default view in the Ajax response.

I have the default view and layout defined in coldbox.cfc

The ajax call look like this:

I have a number of handlers that return data in different formats, depending on the type of request. For AJAX requests (event.isProxyRequest()), I use event.renderData( type=“json”, data=mydata). This returns the data in a nice JSON format and does not include the default view. http://wiki.coldbox.org/wiki/EventHandlers.cfm#Rendering_Data

I tried the event.renderData method in the handler and not returning anything, but it still wants to include the default view with the response. Thanks.

if you use the proxy, views are not rendered. you can also use event.isProxyRequest().

I am using the proxy. I did a little more digging and the default event is being called for the Ajax request. When I call the Ajax event via a URL in a browser, it looks fine, but when it’s called via the actual web page using javascript for some reason coldbox is calling the default event. The JSON is appended to the end of the request, but the html from the default event call is there as well. Any ideas?

So I’m still having this problem. I actually had to set a session variable the first time the default view is called to keep if from rendering on subsequent calls. In the event handler function event.isAjax() or event.isProxyRequest() don’t work. They always return false. Coldbox simply does not have a clue that this is a proxy or ajax request. Any help appreciated. Thanks.

Jim

To use the proxy, you have to send all ajax requests through the proxy.cfc. Is that the case?

You create a CFC that extends the base proxy and then create a method in it to call. You can also make Ajax calls to regular old events as long as you use renderData to return what the client expects (JSON/XML).

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com