473,320 Members | 1,804 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Javascript in a page loaded through ajax

42
I am loading a page using ajax,
but the problem is that the javascript functions existing on that page would no longer be available when loaded through ajax,

is there anyways to load a page in a way that the javascript functions on that page would still work,

I am loading some pages that do not belong to me and I can not create javascripts that would support their pages too,
Jul 23 '07 #1
3 1879
kovik
1,044 Expert 1GB
AJAX can't load the JavaScript on the new page because JavaScript is handled client-side through browsers, and when you run an AJAX call, there is no browser middle-man to interpret the code.
Jul 23 '07 #2
pbmods
5,821 Expert 4TB
Heya, xhunter. Welcome to TSDN!

If all you need to do is load the content of that page, why not just redirect the browser?

Expand|Select|Wrap|Line Numbers
  1. location.href = 'http://somewhere-else.tld';
  2.  
Jul 24 '07 #3
neomhm
1
Hi and sorry for the late reply.

I saw this post a couple of months ago and was interested in loading javascript run script from a loaded AJAX page.

Actually you can... it took a lot of brain storm and coding to finally identify a quick and easy fix.

Just load the javascript code when loading the main page all together (do it invisibly in the background, basically put in the script without calling it).

Then load the ajax page (the javascript should be there too), and call the Javascript function..... tada.. it works...

What happened?

The fact that you called the same javascript function while loading the main page identified the code toward the browser... so when called ... it actually reacts.

Do not forget that Javascript is fully loaded when a page is called and is a browser sided language.

I hope that it did help someone.

Cheers

Laurent Chammas -- Juba, South Sudan.
Jun 23 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: sgmaat | last post by:
I have create a AJAX webpage where if you press a link content is loaded into a div. NOw when this content is loaded no javascript is processed (i.e <Script>alert(..);</script>), but if the...
3
by: wolis | last post by:
Hi all, In an AJAX environment, is it possible to load and display some HTML and JavaScript and have that JavaScript functional? I have tried but the JavaScript functions dont appear to be...
2
by: www.gerardvignes.com | last post by:
I am using this to load the client JavaScript for a web application when it is selected by the user) via an Ajax connection to the server. I have found only two ways of loading new JavaScript...
22
by: Christopher Nelson | last post by:
I have a little menu system which essentially takes HTML like: <div id='foo'></div> and retrieves foo.shtml from the server and inserts it inside the <div>. But sometimes I'd like foo.shtml...
3
by: battle.chris | last post by:
Hello. I'm using Prototype's Updater class to refresh sections of a page. Is there a way to include an external javascript files in the updated content; i.e., have a javascript tag with src...
34
by: ojvm | last post by:
Hi every body. as my post says, i want to add javascript to my page on the fly. for example page1.html <html> <head> <script type='text/javascript'src='controlador.js'></script> ...
1
by: wenijah | last post by:
Hi everyone! First thank you for reading this post and yes, you probably already see that kind of topic title somewhere but the problem I've got today might be different than the 100 topics I've...
1
by: finco | last post by:
Hi all - can someone please point me in the right direction. I have pages that launch their javascript components fine if the page is loaded on its own. But when the page is loaded AJAX the...
3
by: krg | last post by:
Hi, I started writing this blog some time back and it would be great if I could get an audience here and even better if we could have a conversation about developments possible on the techniques I...
5
Frinavale
by: Frinavale | last post by:
I was just wondering where/how JavaScript is loaded? Is it loaded for the specific page or for the Browser? I would have thought it was just specific to the page that the JavaScript exists within...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.