Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cfwddx, cfml2js, and arrays 1

Status
Not open for further replies.

riluve

Technical User
Mar 11, 2005
78
0
0
US
So I am using JSMX and CFMX. I have them working using a simple object or CFFuntion output, but I need to transfer an array (really a recordset).

I believe I have the server side working properly, but how do I address the resulting array in JS?

Sample code:
-server side-----------
<cfsetting enableCFoutputOnly="Yes" showdebugoutput="No">
<cfquery name = "q" dataSource = "RF02">
select Folio_Dir, Folio_Name from Folios_
</cfquery>
<cfwddx action="CFML2JS" input= "#q#" toplevelvariable="result">

-client side------------
<script>
function Request(){ http( 'GET', 'jsmx.cfm', Response); }
function Response(){ alert(WddxRecordset.result[0]);}
</script>
 
I notice that you cross posted on Coldfusion. However, this seems to be a specific JavaScript question, on how to deal with an array of objects being returned (you already know how to process one object).

Try asking in the Javascript forum, forum216, where over 38000 members are waiting to answer. :-D

Tom Morrison
 
I think that this is going to happen a lot in an AJAX forum. AJAX isn't a specific language or anything so questions are probably going to be best answered in their respective forums (like asp.net, php, javascript, etc).

Just my opinion...
 
AJAX isn't a specific language or anything
? I thought AJAX was a specific language (JavaScript), i think the problem here is trying to use it in the wrong away.

All AJAX does is the same as if you had typed a URL into the browser including the querystring, it is processed by the server and either X/HTML,TEXT or XML is passed back.

You do not pass back to the browser recordsets, arrays or any other server side language specific code (so ASP, CF, PERL, PHP, SSI etc.. won't work).

you can pass back an XML file which can be record set data, but you would have to use JavaScript to parse the file.

Hopefully this helps explain AJAX a little better :)



"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Actually, you CAN pass back language specific code - if that code is javascript code. It can be eval'ed by your javascript program. This is how JavaScript Object Notation (JSON) works. It's a very handy way to pass structured data back to your javascript code that it can easily use.

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Excellent Tracey, good job, never heard of JSON before, something else i'm gonna have to now learn ;-)

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Unless you know a LOT about javascript, the syntax of javascript object notation can be quite confusing. I'll see if I can come up with a simple example and post it here later.

If you're working with vbscript on the server side, I have a function that will translate an ADO recordset into JSON that I can post. It is quite handy. You're javascript routine can work with the recordset quite neatly.

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
sounds great, any chance you got a PERL one up ya sleeve ;-)

[turn an array of hashes into a JSON recordset]

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
I might be able to come up with one, but it's been years since I've written anything in PERL. It shouldn't be difficult to write one though. I'm about to post a FAQ about JSON that should give you enough to go on.

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
AJAX is not just Javascript, you need to have a server-side language to do the processing, which is the point of AJAX. Personally I use asp.net, so if I have a question on ajax I would either post my question in a) the javascript forum, or b) the asp.net forum.

For example, I implement the ICallbackEventHander for asp.net 2.0, I seriously doubt that a php programmer is going to be able to help me with that, regardless of how ajax knowledgable they are.

Not trying to be a jerk or anything, that's just the way I see it...

Having said that, I do intend to try to support this forum, just like I do every other forum on tek-tips ;-)
 
jshurst,

Looking at your profile, and assuming you are able to carry through on your intent to support AJAX forum, I don't think PHP programmers will feel any need to answer an ASP question. So far there are some strong Javascript folks here, my strength is XML/XSLT, and now we have you too. :-D

You raise a question that was raised during the debate about creating this forum. The fact is that there was not a single place to ask an AJAX-related question prior to this forum, so you would see questions in Javascript, PHP, even XML, and often ending in some frustration due to lack of correct forum focus. So, this forum is centered on a methodology and/or the technique of integrating several lnaguage-specific technologies, rather than just a language. The forum carries the name General AJAX Discussion rather than just AJAX in recognition of that fact. We will try to cope with the language-specific questions as they appear, answering those that are AJAX related here, and sending others to a correct forum as it seems appropriate. All in all, I hope that the existence of an AJAX forum better serves the Tek-Tips community than would its absence, 'cause that's what it is all about.

Tom Morrison
 
jshurst: You are correct in what you say, however there are some issues with AJAX that may be better addressed in this forum than in a language specific one, such as the design descisions involved in using AJAX, security issues, and cross-language issues (such as returning a JSON object from a VBScript program). Let's give this forum a chance and see how things work out.

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
I see what you guys are saying, and I've already learned about the JSON (or at least it's in my vocabulary now), so this forum has already taught me something.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top