Re: Ajax, Json, and two clueless programmers

2010-03-28 Thread Tony Bentley


houseDetails = {address : 1970 ST CHESTER AURORA, 80010,  price :
45000,listingNum : 833553, office : 303-487-0777 };



The returned info (price, for example) displays great with ID numbers
in a table as such: td id=price/td or  like this p
id=price/p...  but how the heck do I use it in a URL and (most
importantly) pass other variables with it, for example: a
href=?from=doitprice=PRICEVARIABLEHERE and have that link info
change without refresh right along with the rest of the page?


Using javascript you can access the json as a structure; houseDetails.price 
returns 45000.
So basically once the dataset is returned you can use it to build your url 
string.It really helps to use a framework or library that is meant to work with 
json and ajax. Try prototype or jquery.

I can write the following:

document.createElement(a).href=index.cfm?price=+houseDetails.price;


You can also access elements by their id or relative position to other easily 
accessed elements in jQuery or Prototype

So really if your dev guy is a good client side developer, you should handle 
all of the cfc methods for him and have him do all of the javascript and client 
side development. Or are you trying to learn how to write javascript? 

~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:332396
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Ajax, Json, and two clueless programmers

2010-03-28 Thread Dave l

first I would use jquery to make it easier but if neither of you know it the 
first hurdle you will face is multiple clicks so you should put a div and class 
around each link and then use jquery's live property which will make this 
work right or else you'll be scratchin your head trying to get it.

then in the same function use jquery ajax function to grab info.

Also cfm returns json IN ALL CAPS, so propertyID becomes PROPERTYID in the 
returned json.

$(function() {
$('td.propertyInfo').live('click',

var PropertyID = this.id;
//the line below is used with a regex to help filter data faster by 
adding a
// longer more specific name to the link to speed it up and then the 
regex
// removes the additional text: example would be: the table row would 
be 
//property id but you shouldn't use that id if it's just a number so 
adding 
//property-#propertyID# separates the value from any other possible 
conflicts.
var getDataString = $(this).attr('id').replace(/property-/ig, '');
var dataString = id= + getDataString;
$.ajax({
type: post,
url: assets/cfc/process.cfc?method=getPTreturnFormat=json,
data: dataString,
dataType: json,
cache: false,
success: function(data) {
//success code here
} else {
$('#submitIt div').removeClass('btnSpin');
 //error code here  
}
}
});
return false;
});
return false;
}); 

~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:332398
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


RE: Ajax, Json, and two clueless programmers

2010-03-28 Thread andy matthews

Just to clarify that CF ONLY returns JSON in all caps if you use dot
notation. Try it out yourself.

Dot notation
VARIABLES.myStruct.myKey - VARIABLES.MYSTRUCT.MYKEY

Bracket notation
VARIABLES['myStruct']['myKey'] - VARIABLES.myStruct.myKey




-Original Message-
From: Dave l [mailto:cfl...@jamwerx.com] 
Sent: Sunday, March 28, 2010 7:30 PM
To: cf-talk
Subject: Re: Ajax, Json, and two clueless programmers


first I would use jquery to make it easier but if neither of you know it the
first hurdle you will face is multiple clicks so you should put a div and
class around each link and then use jquery's live property which will make
this work right or else you'll be scratchin your head trying to get it.

then in the same function use jquery ajax function to grab info.

Also cfm returns json IN ALL CAPS, so propertyID becomes PROPERTYID in the
returned json.

$(function() {
$('td.propertyInfo').live('click',

var PropertyID = this.id;
//the line below is used with a regex to help filter data faster by
adding a
// longer more specific name to the link to speed it up and then the
regex
// removes the additional text: example would be: the table row
would be 
//property id but you shouldn't use that id if it's just a number so
adding 
//property-#propertyID# separates the value from any other
possible conflicts.
var getDataString = $(this).attr('id').replace(/property-/ig, '');
var dataString = id= + getDataString;
$.ajax({
type: post,
url: assets/cfc/process.cfc?method=getPTreturnFormat=json,
data: dataString,
dataType: json,
cache: false,
success: function(data) {
//success code here
} else {
$('#submitIt div').removeClass('btnSpin');
 //error code here  
}
}
});
return false;
});
return false;
}); 



~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:332400
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm