<Solved> jQuery Ajax with JSON problem
Hi all, I've used jQuery for a while and I've done a fair many ajax requests with JSON and have always been able to figure out my problems. This time around I'm stumped, I haven't figured out the problem.
Here's what I'm doing, I have an ajax post request that happens on a change event of a select box. The AJAX request gets information about the client to pre-populate some data fields to accelerate the data entry process. The request receives the data back in a JSON format which I then access to populate the fields. The problem is, it's not populating the fields and it appears I'm getting a valid JSON object back.
Here's the jQuery code (Yes, I also use ColdFusion and you see a smidgen of that in there, the problem is definitely NOT there)
-
jQuery("#client_list").change(function(){
var itemVal = jQuery("#client_list").val();
var mode = "getClient";
var url = "http://<CFOUTPUT>#CGI.server_name##CGI.SCRIPT_NAME#</CFOUTPUT>"; //yes, this has ColdFusion on it
jQuery.post(url, {
mode: mode,
itemId: itemVal
}, function(data){
jQuery("#email").val(data.businesscontactemail);
jQuery("#phone").val(data.businessphone);
jQuery("#url").val(data.businessurl);
jQuery("#address").val(data.businessaddress);
jQuery("#city").val(data.businesscity);
jQuery("#state").val(data.businessstate);
jQuery("#zip").val(data.businesszip);
}
,"json");
});
I have run Fiddler to get the headers and see what's being passed in and returned. Here is what is being returned: (I modified some text due to security concerns)
-
{"COLUMNS":["BUSINESSURL","BUSINESSADDRESS","BUSINESSCITY","BUSINESSSTATE","BUSINESSZIP","BUSINESSPHONE","BUSINESSCONTACTEMAIL"],
"DATA":[["http:\/\/www.airtoofly.com","403 Fairacre Court","fake_city","PA",15142.0,"(904) 806-6238","fakeemail@hotmail.com"]]}
I've tried alerting the specific columns of the JSON object and it always comes back undefined.
Any ideas?