473,569 Members | 3,009 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Javascript in a page loaded through ajax

42 New Member
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 1886
kovik
1,044 Recognized Expert Top Contributor
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 Recognized Expert Expert
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 New Member
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
2141
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 javascript is in <a onclick="..."> it will work. What i would like to know is: - Is this normal - What do i need to change so that javascript does get...
3
1661
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 visible - Im assuming this is becasue they were not loaded when the initial AJAX application/page originally loaded. Conceptual example if it helps:
2
1877
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 after the web page is loaded. 1. Create a new script element (where head is the id of the head tag): var s = document.createElement('script');...
22
2300
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 to look like: <script language='JavaScript'> ...do something AJAX-y </script>
3
2051
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 attribute? Can't seem to get this to work. Also, if there is a way, will the browser cache any dynamically loaded scripts?
34
9645
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> <title>...</title>
1
3179
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 seen so far that did not resolve my problem... Environment and problem: I have a page A with Ajax.js and a <div id="ajx">Content</div> that changes...
1
1173
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 javascript does not fire. An example is this simple web page: <html> <head> <title></title> </head> <body> <script...
3
1771
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 have discussed in my blog. Automatic Javascript Bug Reporting Using AJAX http://krahulg.wordpress.com/2007/12/24/automatic-javascript-bug-...
5
2613
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 but I've been experiencing something a little weird lately with regards to FireBug. I'm getting an error message: Now the interesting thing...
0
7703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7930
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8138
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6290
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3662
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2118
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1229
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.