renderWith() not doing it's job

97 views
Skip to first unread message

kristof polleunis

unread,
Nov 2, 2012, 12:52:36 PM11/2/12
to cfwh...@googlegroups.com
I have an ajax call that updates or sets a value and this ajax script works fine.  I can see the data being updated or added in the database.

Now the function it is calling (index) seems to do the update and insertion of the data.  To provide feedback to the callback function it's also supposed to render the some output as json


 some checks
...
userprogram.save();
<!--- Prepare the message for the user --->
response = {};
response["message"] = "Saved";
response["programid"] = "#userprogram.programid#";
<!--- Respond to all requests with `renderWith()` --->
renderWith(response);

It doesn't seem to output any json at all but just loads the index.cfm in the views folder which is then send to the javascript.  I used jquery for the ajax and have set provides(html, json) in the init part.

I can't figure out what is wrong here, no error messages at all and it was something I had working some time ago.

Yannick Morin

unread,
Nov 2, 2012, 1:04:57 PM11/2/12
to cfwh...@googlegroups.com
Hi Kristof,

Can you show us your ajax code.

THanks


--
You received this message because you are subscribed to the Google Groups "ColdFusion on Wheels" group.
To view this discussion on the web visit https://groups.google.com/d/msg/cfwheels/-/DNunS83YorQJ.
To post to this group, send email to cfwh...@googlegroups.com.
To unsubscribe from this group, send email to cfwheels+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cfwheels?hl=en.

Chris Peters

unread,
Nov 2, 2012, 1:20:54 PM11/2/12
to cfwh...@googlegroups.com
You may want to consider using renderText() instead of renderWith():
renderText(SerializeJson(response));

I think renderWith() is going to cause it to expect an index.json.cfm because you're not really giving it supported construct like a query or array of model objects. I could be wrong on this though, so someone correct me if I'm wrong.

Samson Quaye

unread,
Nov 2, 2012, 2:18:27 PM11/2/12
to cfwh...@googlegroups.com
+1 to Chris Peters suggestion.

kristof polleunis

unread,
Nov 2, 2012, 2:45:50 PM11/2/12
to cfwh...@googlegroups.com
Yannick, the ajax code is working fine

kristof polleunis

unread,
Nov 2, 2012, 2:47:25 PM11/2/12
to cfwh...@googlegroups.com
Chris, Samson,

With renderText it's working.

I just thought that in the docs it said renderWith() would automatically transform the data

Automatic Generation of XML and JSON Formats
If the requested format is xml or json, the renderWith() function will automatically transform the data that you provide it. If you're fine with what the function produces, then you're done!

Chris Peters

unread,
Nov 2, 2012, 2:49:47 PM11/2/12
to cfwh...@googlegroups.com
Guess it only supports certain data constructs. Seems like it should do its own SerializeJson() if it's not a "supported" construct.

Last thing I'll ask is what if you change it to answer to "js" instead of "json"?


--
You received this message because you are subscribed to the Google Groups "ColdFusion on Wheels" group.
To view this discussion on the web visit https://groups.google.com/d/msg/cfwheels/-/J5iacXNOLtMJ.

Bill

unread,
Nov 3, 2012, 6:51:24 PM11/3/12
to cfwh...@googlegroups.com
Are you using ?format=json in the ajax request url?
Reply all
Reply to author
Forward
0 new messages