artacus Posted December 4, 2006 Share Posted December 4, 2006 I am using Javascript to create the contents of a page (in this case a CSV file I want to save). If you've worked with Ajax for more than a day, you know that it modifies the DOM but the browser does not show those changes when you view source or, more important to me at the moment, save the page.Is there some way to make the browsers save the Javascript changes instead of the original document? Quote Link to comment https://forums.phpfreaks.com/topic/29455-saving-an-ajax-page/ Share on other sites More sharing options...
ToonMariner Posted December 5, 2006 Share Posted December 5, 2006 give the place holder ofthe info in the html page an id and use javscript to format the contents of the csv file into a html string then use document.getElementById('placeholderid').innerHTML = thestring; Quote Link to comment https://forums.phpfreaks.com/topic/29455-saving-an-ajax-page/#findComment-135257 Share on other sites More sharing options...
artacus Posted December 5, 2006 Author Share Posted December 5, 2006 Yeah, I have no problem getting the data there. The problem is that FF (its an Intranet app) won't save any data that has been loaded using Javascript. Quote Link to comment https://forums.phpfreaks.com/topic/29455-saving-an-ajax-page/#findComment-135306 Share on other sites More sharing options...
ober Posted December 5, 2006 Share Posted December 5, 2006 I'm not aware of a way to do this and be able to view the source via the normal "view source" options. However, one of the browsers (I swear it was FF), allows you to highlight the changes returned by AJAX and use "view selection source" or something similar. That will show you the result. Quote Link to comment https://forums.phpfreaks.com/topic/29455-saving-an-ajax-page/#findComment-135481 Share on other sites More sharing options...
artacus Posted December 5, 2006 Author Share Posted December 5, 2006 Yeah, FF lets you see the changes if you use 'view selection source'. But can you imagine trying to walk your typical user thru that process? Step 1. CTRL + A To select allStep 2. CTRL + S To saveStep 3. Save as file with CSV extensionStep 4. Find that file and open with excelIt would result in more work orders than it would be worth. Quote Link to comment https://forums.phpfreaks.com/topic/29455-saving-an-ajax-page/#findComment-135530 Share on other sites More sharing options...
ober Posted December 5, 2006 Share Posted December 5, 2006 ... why would you want your user to view your source!?! Why wouldn't you just present a csv file to them and let them click and download it? Am I missing something? Quote Link to comment https://forums.phpfreaks.com/topic/29455-saving-an-ajax-page/#findComment-135546 Share on other sites More sharing options...
artacus Posted December 5, 2006 Author Share Posted December 5, 2006 [quote author=ober link=topic=117356.msg479149#msg479149 date=1165340010]... why would you want your user to view your source!?! Why wouldn't you just present a csv file to them and let them click and download it? [/quote]That's exactly what I WANT to do. But since my data is being generated by Javascript after the page loads, it will save the file as it existed BEFORE Javascript added the data. Quote Link to comment https://forums.phpfreaks.com/topic/29455-saving-an-ajax-page/#findComment-135683 Share on other sites More sharing options...
ober Posted December 5, 2006 Share Posted December 5, 2006 Maybe AJAX isn't the answer then... I'd suggest using an iframe or something similar. Quote Link to comment https://forums.phpfreaks.com/topic/29455-saving-an-ajax-page/#findComment-135707 Share on other sites More sharing options...
artacus Posted December 5, 2006 Author Share Posted December 5, 2006 Its looking like I'll end up doing it in PHP. I wanted to do it with Javascript because I've already done all of the work (well PHP/MySQL has) to generate an HTML table with possibly 1,000's of records. I didn't want to waste resources doing it over again when it was so easy to convert the table to CSV. *Sigh* You win some you lose some. I'm just not accustomed to losing. Quote Link to comment https://forums.phpfreaks.com/topic/29455-saving-an-ajax-page/#findComment-135736 Share on other sites More sharing options...
ober Posted December 6, 2006 Share Posted December 6, 2006 What are you losing? I don't get it. There's no reason you can't create the CSV file on the server for a specified amount of time and then just give them a link to it. Quote Link to comment https://forums.phpfreaks.com/topic/29455-saving-an-ajax-page/#findComment-135847 Share on other sites More sharing options...
artacus Posted December 6, 2006 Author Share Posted December 6, 2006 Alright, I wouldn't have thought of that approach. I can process the list once and create my HTML output and the CSV file at the same time. And just cache the CSV file for a few minutes. I like it. Thanks ober. Quote Link to comment https://forums.phpfreaks.com/topic/29455-saving-an-ajax-page/#findComment-135854 Share on other sites More sharing options...
ober Posted December 6, 2006 Share Posted December 6, 2006 Anytime... although I normally just have a script in a page like that that will delete any CSV files older than 15 or 30 min. It's an easy script and works like a charm. So the next time someone opens that page, it'll run that script. Quote Link to comment https://forums.phpfreaks.com/topic/29455-saving-an-ajax-page/#findComment-135899 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.