471,089 Members | 1,188 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,089 software developers and data experts.

to ajax or not


I am fixing up a site where the address data for all the addresses for
each customer is called with 1 query and then added to a javascript
array. The street name of each shipping addresses is available in a
dropdown menu. When an address is chosen, the details are displayed
for editing in input fields under the menu.

The addresses are either US , international or military addresses.
Most of the fields are common to all types of addresses, buy each type
of address also has some unique fields. When the address is chosen, I
want only the relevant fields to display.

Option 1: The site originally had all the fields on each page no
matter which type of address was selected. Each field was made
visible or invisible as needed with javascript, but this left empty
spaces where the unused fields were.

Option 2: I could create the unique fields with ajax, and then fill
them in with data from the address array. I tried this, and it seems
like the script tries to validate the fields before they are created,
even if the validation comes after the ajax call. I don't like the
idea of using a timer, so is there any other way to have the script
wait until the ajax section is done before proceeding ?

Option 3: I could call only the address ids and street names when the
page loads, and then use ajax to call and display the address data for
each address when the user chooses it. This means a query for each
address, but that doesn't seem like a big deal.

Option 4:I could forget ajax calls entirely and use javascript to
construct and delete only the unique input fields as they are needed.
This seems javascript heavy, but it works fine and I'm leaning in this
direction.

What's the right way to do this ?

Jun 12 '07 #1
2 1238
gr*****@reenie.org wrote:
>
I am fixing up a site where the address data for all the addresses for
each customer is called with 1 query and then added to a javascript
array. The street name of each shipping addresses is available in a
dropdown menu. When an address is chosen, the details are displayed
for editing in input fields under the menu.

The addresses are either US , international or military addresses.
Most of the fields are common to all types of addresses, buy each type
of address also has some unique fields. When the address is chosen, I
want only the relevant fields to display.

Option 1: The site originally had all the fields on each page no
matter which type of address was selected. Each field was made
visible or invisible as needed with javascript, but this left empty
spaces where the unused fields were.

Option 2: I could create the unique fields with ajax, and then fill
them in with data from the address array. I tried this, and it seems
like the script tries to validate the fields before they are created,
even if the validation comes after the ajax call. I don't like the
idea of using a timer, so is there any other way to have the script
wait until the ajax section is done before proceeding ?

Option 3: I could call only the address ids and street names when the
page loads, and then use ajax to call and display the address data for
each address when the user chooses it. This means a query for each
address, but that doesn't seem like a big deal.

Option 4:I could forget ajax calls entirely and use javascript to
construct and delete only the unique input fields as they are needed.
This seems javascript heavy, but it works fine and I'm leaning in this
direction.

What's the right way to do this ?
Well, I can't say this is the right way, but wouldn't Option 1 work if
you use "display:none" to hide the irrelevant items? They wouldn't take
up space in the layout.
Jun 12 '07 #2
On Jun 12, 3:40 pm, Gary Hasler <garyhas...@thelogconnection.com>
wrote:
grou...@reenie.org wrote:
I am fixing up a site where the address data for all the addresses for
each customer is called with 1 query and then added to a javascript
array. The street name of each shipping addresses is available in a
dropdown menu. When an address is chosen, the details are displayed
for editing in input fields under the menu.
The addresses are either US , international or military addresses.
Most of the fields are common to all types of addresses, buy each type
of address also has some unique fields. When the address is chosen, I
want only the relevant fields to display.
Option 1: The site originally had all the fields on each page no
matter which type of address was selected. Each field was made
visible or invisible as needed with javascript, but this left empty
spaces where the unused fields were.
Option 2: I could create the unique fields with ajax, and then fill
them in with data from the address array. I tried this, and it seems
like the script tries to validate the fields before they are created,
even if the validation comes after the ajax call. I don't like the
idea of using a timer, so is there any other way to have the script
wait until the ajax section is done before proceeding ?
Option 3: I could call only the address ids and street names when the
page loads, and then use ajax to call and display the address data for
each address when the user chooses it. This means a query for each
address, but that doesn't seem like a big deal.
Option 4:I could forget ajax calls entirely and use javascript to
construct and delete only the unique input fields as they are needed.
This seems javascript heavy, but it works fine and I'm leaning in this
direction.
What's the right way to do this ?

Well, I can't say this is the right way, but wouldn't Option 1 work if
you use "display:none" to hide the irrelevant items? They wouldn't take
up space in the layout.
You know what? I think that is the best overall method. Thanks for the
tip!
If I had thought of that I probably wouldn't have thought of all the
other methods.

Jun 13 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by Yarco | last post: by
4 posts views Thread by bobzimuta | last post: by
reply views Thread by melledge | last post: by
1 post views Thread by www.web20developers.com | last post: by
10 posts views Thread by =?Utf-8?B?WWFua2VlIEltcGVyaWFsaXN0IERvZw==?= | last post: by
2 posts views Thread by soni2926 | last post: by
11 posts views Thread by =?Utf-8?B?R2VyaGFyZA==?= | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.