Author |
Topic  |
|
ILLHILL
Junior Member
 
Netherlands
341 Posts |
Posted - 24 June 2007 : 16:20:08
|
Here's a problem I'm bumping into:
I have an asp page (index.asp), which, when loaded, loads some seperate .txt files inside the page, through "include file". The data from these is in html, so, containing html and css and javascript references.
Now, when the page is loaded from scratch and the txt files are loaded with the include file, all goes well. So the javascript in the loaded/included .txt files works.
Now, it is possible to replace the included textfiles with a javascript command, which will then load another txt file into the div where the included txt file's date used to be in.
However, when the ajax/javascript is used and the data from a new .txt file is loaded and displayed, then the javascripts from the new data does not work.
Now, when a new txt file is loaded, a cookie is set, when you refresh the page, the "new" txt file, which was first loaded through ajax, is now loaded through include file. Then the javascript works.
Maybe it's better to show you the example: visit http://www.clppr.com then click any of the headlines. You will then see how the link is loaded in a new layer.
Now, close that layer with the X button, then click "change rss" (or one of the edit-buttons) and select a new rss file from the pulldown.
Now, when this rss is loaded and you click a headline from this new parsed data, it will simply load the link as a page (not in the css frame). Refresh clppr and the rss you selected will then be loaded through include file. Now when you click a link it will be loaded in the css frame (yet again).
So, why does the javascript no longer work when a txt file is loaded through ajax?
I tried my best to explain, but if not clear please don't hesitate to ask.
Greets & thanks,
Dominic
|
CLPPR.com - All The News Only Seconds Away |
|
Zuel
Average Member
  
USA
540 Posts |
Posted - 24 June 2007 : 16:46:26
|
I could be completely wrong, but when a page first loads the browsers javascript interperter reads all the javascript on the page and creates little pointers so when a user clicks a link or triggers an event, the browser can find it.
This happens as the page loads.
What you are doing is adding code after the page loads using AJAX and since the interperter already ran, the new javascript won't work.
It is considered "dangerous" to allow javascript to create javascript. |
My Completed Mods: News Mod | Zuel's Avatar Add-on In Development: World of Warcraft Member Roster | [C# Based Forum]
Note - I may take a few days to recieve your email. Hotmail filters all new emails as junk. Would be best to post all questions, concerns in a forum topic to catch my immediate attention. This way others can assist and also correct any similar mistakes.
MSN / E-Mail: ucyimDa_Ruler@Hotmail.com
Personal Bookmarks: How to work a DBS File
|
 |
|
ILLHILL
Junior Member
 
Netherlands
341 Posts |
Posted - 24 June 2007 : 19:29:25
|
Hmmm... might there be a workaround? For example, then indexpage contains an include for the vbs functions. The parsing pages that get loaded through include file, logically, recognize the vbs functions. The parse page version that loads through ajax, did not recognize the functions, so I added a separate include to the copy parse page, including the functions, so then it worked.
Is there a way, to load the necessary javascript into the ajax-loaded page? (The javascript gets called in the <head> and since the parse page doesn't have a header at all, is it even possible?)
Else it's back to plan a :(
Thanks for your comment!
Greets & thanks, Dominic |
CLPPR.com - All The News Only Seconds Away |
 |
|
Zuel
Average Member
  
USA
540 Posts |
Posted - 24 June 2007 : 21:02:46
|
As long as your methods are loaded at page load, you should be able to dynamically call them.
That is the only way. |
My Completed Mods: News Mod | Zuel's Avatar Add-on In Development: World of Warcraft Member Roster | [C# Based Forum]
Note - I may take a few days to recieve your email. Hotmail filters all new emails as junk. Would be best to post all questions, concerns in a forum topic to catch my immediate attention. This way others can assist and also correct any similar mistakes.
MSN / E-Mail: ucyimDa_Ruler@Hotmail.com
Personal Bookmarks: How to work a DBS File
|
 |
|
Doug G
Support Moderator
    
USA
6493 Posts |
Posted - 25 June 2007 : 01:06:27
|
If you're using classic asp includes with #include file="whatever" statements, here's how things flow:
- User requests somepage.asp The .asp tells IIS to start the asp dll. - asp.dll scans somepage, sees there are includes, and retrieves and merges the includes into an "uber-page" code base - Now asp.dll starts executing asp code in the server - asp code generates html to send to the browser, either by response.write or non-asp code html blocks. - The browser receives the html and assembles it's page, including any script files, image files, etc. The server asp page may have already completed by this time. - The browser renders the page and does any scripts that run on page load.
The above flow happens whether or not you're using ajax technology. Here's how ajax picks up when the browser page is rendered.
- User clicks something that needs an ajax call - Browser script uses the xmlHTTP object to perform a GET or POST to an ajax-enabled page on the web server - Server page does whatever, and any results are sent back to the browser via xmlHTTP - Browser script extracts the results from it's xmlHTTP object, and then does whatever with the results, such as changing the innerHTML of an HTML element or something.
This is my understanding of how asp and ajax work.
|
====== Doug G ====== Computer history and help at www.dougscode.com |
 |
|
ILLHILL
Junior Member
 
Netherlands
341 Posts |
Posted - 25 June 2007 : 12:05:42
|
Hmmm... funny thing is that it should actually work, as far as I can see.
I tried to have the ajax loaded page render something like a href=javascript: popup( link ) and that actually worked.
So, theoretically, one should assume that the greybox code I'm using should work too (which looks something like: A href="the link" title="the title" rel="gb_page_center[1000, 500%]")
So, it seems fair to assume that with the script preloaded in the index page and things like PopUp and ExpandCollapse working even in the ajax rendered page, that the gb_page_center thingy should also work.
However, I have come across this: http://groups.google.com/group/greybox/msg/1a7c87d627240f65 This person is doing something different from what I am doing, however, his situation is similar (and maybe a bit better explained than my attempt).
I will try again to find a greybox community, cause maybe this is a known bug.
It's good to know that javascript coding itself is indeed working in a ajax rendered page.
Any suggestions are still welcome and I will keep you posted if I happen to find a solution elsewhere.
Greets & thanks, Dominic |
CLPPR.com - All The News Only Seconds Away |
 |
|
ILLHILL
Junior Member
 
Netherlands
341 Posts |
Posted - 25 June 2007 : 17:46:31
|
Yay! I got it all to work.
The problem was indeed not in a javascript command, but in an extra line of code that needed to be added in order to make it work :)
http://www.clppr.com works like a charm now... just some small adjustments and it's out of Beta! :-D
Thanks again for the feedback and explanations!
Greets & thanks,
Dominic |
CLPPR.com - All The News Only Seconds Away |
 |
|
Shaggy
Support Moderator
    
Ireland
6780 Posts |
Posted - 26 June 2007 : 04:59:50
|
What did the extra line of code do?
|
Search is your friend “I was having a mildly paranoid day, mostly due to the fact that the mad priest lady from over the river had taken to nailing weasels to my front door again.” |
 |
|
ILLHILL
Junior Member
 
Netherlands
341 Posts |
Posted - 26 June 2007 : 14:36:19
|
I added the line: decoGreyboxLinks(); at the end of the sever_interaction function. That must have activated the function for links in ajax generated pages. Seems like an extra function is called, not entirely sure how it works, just happy that the problem is solved :)
Greets, Dominic |
CLPPR.com - All The News Only Seconds Away |
 |
|
|
Topic  |
|
|
|