Ajax call returning HTML?

70 views
Skip to first unread message

Darryl Tharpe

unread,
Oct 31, 2014, 8:39:17 AM10/31/14
to cfwh...@googlegroups.com
Hello,

When I make an ajax call in new version of wheels, 1.3.1, to a function named getSearchData it returns HTML, but if I paste the same code in the function which corresponds with the action, like index or edit it works? I have did this hundreds of times in Wheels but trying out the new version, did something change?

Chris Peters

unread,
Oct 31, 2014, 9:03:58 AM10/31/14
to cfwh...@googlegroups.com
It's unclear what you're asking. Can you provide clear, minimal examples with code?

On Fri, Oct 31, 2014 at 8:39 AM, Darryl Tharpe <dtha...@gmail.com> wrote:
Hello,

When I make an ajax call in new version of wheels, 1.3.1, to a function named getSearchData it returns HTML, but if I paste the same code in the function which corresponds with the action, like index or edit it works? I have did this hundreds of times in Wheels but trying out the new version, did something change?

--
You received this message because you are subscribed to the Google Groups "ColdFusion on Wheels" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cfwheels+u...@googlegroups.com.
To post to this group, send email to cfwh...@googlegroups.com.
Visit this group at http://groups.google.com/group/cfwheels.
For more options, visit https://groups.google.com/d/optout.



--

Chris Peters
Web Developer
Liquifusion Studios

chris....@liquifusion.com
Skype: liquifusion.support
www.liquifusion.com

Darryl Tharpe

unread,
Oct 31, 2014, 9:16:28 AM10/31/14
to cfwh...@googlegroups.com
Sure, basically I can name a function in a controller and and pass the URL in the ajax call to it -> url: '/People/index.cfm/BigPeople/getBigPeopleData?&format=json', with getBigPeopleData being the function,  and it would return me the json object. The work around I found was this -> url: '/People/index.cfm/BigPeople/?action=getBigPeopleData&format=json'. So before I didn't have to provide the action in the URL string.

Thanks for your help...

Darryl Tharpe

unread,
Oct 31, 2014, 9:20:09 AM10/31/14
to cfwh...@googlegroups.com
Sorry here is the code....

People.cfc
<cfcomponent extends="People.controllers.Controller">
<cffunction name="init">
<cfscript>
provides("html,json");
</cfscript>
</cffunction>

<cffunction name="index">
</cffunction>

<cffunction name="getSearchData">
<cfscript>
var people = model('People').findAll();
renderWith(people);
</cfscript>
</cffunction>

</cfcomponent>

data.js
var getSearchData = function(type){
switch(type){
case 'people':
var searchData;
$.ajax({
type: 'GET',
url: '/RSPHPeople/index.cfm/people/?action=getSearchData&format=json',
dataType: 'json',
async: false,
success: function(data){
searchData = data;
}
});
return searchData;
break;
}
};

On Friday, October 31, 2014 8:39:17 AM UTC-4, Darryl Tharpe wrote:

Chris Peters

unread,
Oct 31, 2014, 9:49:23 AM10/31/14
to cfwh...@googlegroups.com
It sounds like something isn't working correctly with your URL rewriting or routing. What does your URL rewriting config and routes.cfm look like?

--
You received this message because you are subscribed to the Google Groups "ColdFusion on Wheels" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cfwheels+u...@googlegroups.com.
To post to this group, send email to cfwh...@googlegroups.com.
Visit this group at http://groups.google.com/group/cfwheels.
For more options, visit https://groups.google.com/d/optout.

Darryl Tharpe

unread,
Oct 31, 2014, 12:40:30 PM10/31/14
to cfwh...@googlegroups.com
Sure:

<cfset set(timeStampOnUpdateProperty=false)>
<cfset set(URLRewriting="Partial")>

<cfset addRoute(name="home", pattern="", controller="Main", action="redirect")>
<!--- Faculty --->
<cfset addRoute(name="peopleIndex", pattern="/people/", controller="People", action="index")>

Chris Peters

unread,
Oct 31, 2014, 1:46:33 PM10/31/14
to cfwh...@googlegroups.com
Hmm, I wonder if a bug was introduced in version 1.3.0 or 1.3.1.

Darryl Tharpe

unread,
Oct 31, 2014, 2:09:33 PM10/31/14
to cfwh...@googlegroups.com
Cool, thanks for the help anyways. Ill keep digging and see what I can find. If you find out please let me know, but other than that no problems....

Thanks,

Per Djurner

unread,
Oct 31, 2014, 2:35:42 PM10/31/14
to cfwh...@googlegroups.com
Something doesn't seem right with the routes...

This URL.
/People/index.cfm/BigPeople/getBigPeopleData?&format=json

Is calling something in the "People" folder..

But when you create a route like this:
addRoute(name="peopleIndex", pattern="/people/", controller="People", action="index"

You are pointing it to /index.cfm/people/...

I'm probably not explaining this very well but wanted to at least point out that something seems off to me.

Reply all
Reply to author
Forward
0 new messages