Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-12-2008, 04:57 PM   PM User | #1
Dan06
Regular Coder

 
Join Date: Sep 2008
Posts: 205
Thanks: 1
Thanked 0 Times in 0 Posts
Dan06 is an unknown quantity at this point
Question Monitoring of database updating

I've used an iframe to upload image files to the target server and update the database with the files' location.

However, I'm having trouble with displaying the image once the file is successfully uploaded. I'd like for javascript to monitor the updation of the file location in the database and once the file location information is updated in the database to display the image. Anyone know how to do that? Examples would be great. Thanks.
Dan06 is offline   Reply With Quote
Old 12-13-2008, 01:21 AM   PM User | #2
ohgod
Regular Coder

 
ohgod's Avatar
 
Join Date: Jun 2008
Location: Ohio
Posts: 579
Thanks: 6
Thanked 69 Times in 69 Posts
ohgod is on a distinguished road
are you looking for a change in img info, or just for the existance of it?
ohgod is offline   Reply With Quote
Old 12-15-2008, 04:45 PM   PM User | #3
Dan06
Regular Coder

 
Join Date: Sep 2008
Posts: 205
Thanks: 1
Thanked 0 Times in 0 Posts
Dan06 is an unknown quantity at this point
Both the existence and change of the image info. The first time the user edits the image, there is a null stored in the database. Obviously after the user has inserted the image the first time, there will be a change in image info for all subsequent image insertions.
Dan06 is offline   Reply With Quote
Old 12-15-2008, 09:11 PM   PM User | #4
dk01
New Coder

 
Join Date: Aug 2002
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
dk01 is an unknown quantity at this point
Is the image actually being stored in the database? If so that's a really bad idea.

If not, and the image path/name is the only this stored in the database then I would just add an extra timestamp field called LastUpdated.

When you upload an image just update LastUpdated to reflect the current time.

Your iframe just needs to send an ajax request every so often checking for a timestamp that is not equal to the one from when the page was originally loaded.
dk01 is offline   Reply With Quote
Old 12-16-2008, 03:10 PM   PM User | #5
itsallkizza
Senior Coder

 
Join Date: Oct 2008
Location: Long Beach
Posts: 1,196
Thanks: 36
Thanked 164 Times in 164 Posts
itsallkizza will become famous soon enough
dk is right when he says its generally speaking a bad idea to store anything other than text in a database (for a number of reasons).

That said, he emailed me a couple times and I think figured out a way to get what he wants.

Quote:
Your iframe just needs to send an ajax request every so often checking for a timestamp
While this would work, it's much more efficient and exact to create event driven code rather than cyclical checks. He really just needs it to display when and only when it's been uploaded.
__________________
Feel free to e-mail me if I forget to respond ;)
ohsosexybrit@gmail.com
itsallkizza is offline   Reply With Quote
Old 12-16-2008, 04:14 PM   PM User | #6
Dan06
Regular Coder

 
Join Date: Sep 2008
Posts: 205
Thanks: 1
Thanked 0 Times in 0 Posts
Dan06 is an unknown quantity at this point
No, the image is not being stored in the database, however, the location of the folder/file location is.

I posted my original question sometime ago, and when there were no responses, I re-phrased and re-posted. When there were still no responses, I emailed itsallkizza hoping to pick his mind a bit. After a couple of emails, a simple and effect solution was reached.

I too at first thought of using some repeating code to check if the update was successful/complete. But itsallkizza suggested having the iframe run a js code from the parent document on load - which turned out to be easy and effective.

While on the topic of images, the next task I'm attempting is having a photo album - similar to the ones seen in flickr, facebook, etc. Does anyone have or know of any articles, examples, etc. on how to approach that? General guidlines or suggestions would be appreciated as well. I'd like for the user to be able to upload multiple images at a single time and select orientation. Thanks.
Dan06 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:48 PM.


Advertisement
Log in to turn off these ads.