Please post a sample of your JSON data. You are probably missing a
reference to the first object in your data.
locationData[i].distributor_name should probably be something like:
locationData.distributors[i].distributor_name
On Sep 2, 12:10 pm, "Stephen M. Yeargin"
<stephen.year...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> The error in this script is probably glaring, but my experience with
> AJAX can be measured in hours, not days.
>
> I am modifying a distributor locator map to load filtered lists by
> region. The PHP script (distributor_view_ajax.php) returns a JSON
> object using the JSON.php toolkit if the data parameter is set to
> ''json''. The ''region'' parameter is the
actual search string. On the
> ''onclick'' action of a form, the searchByRegion function
is called.
>
> I''m using Firebug for Firefox to monitor actions/requests, and it
just
> kinda sits there when I push "Search". A few revisions earlier
and I
> was at least able to get a JSON object returned, but not parse-able.
>
> -- JS --
>
> // Grab data if the searchByRegion button was pushed
> function searchByRegion(form){
> var q_region = form.q_region.value;
> new Ajax.Request(''distributor_view_ajax.php'', {
> method:''get'',
> parameters: {''region'' : q_region,
''data'' : ''json''},
> onLoading: function(){
> document.locationsList.innerHTML = ''Loading'';
> },
> onSuccess: function(transport){
> document.locationsList.innerHTML = '''';
> var locationData = transport.responseText.evalJSON();
> for(i=0;i < locationData.length; i++) {
> document.locationsList.innerHTML +>
locationData[i].distributor_name + ''<br />'';
> }
> },
> onFailure: function(){
> document.locationsList.innerHTML = ''Failed.'';
> }
> });
>
> }
>
> - Stephen
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---