473,804 Members | 3,349 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

xmlhttprequest and innerhtml executing javascript

9 New Member
I am posting html onto my main page between div tags using xmlhttprequest and innerhtml. The html I am posting has javascript inside which I am executing using the eval() function. However, the problem I face is that the javascript uses innerhtml as well and will not work for some reason. I have tested the javascript and it is definitely executing, it just will not change the innerhtml.

To be more clear, the innerhtml is trying to access the html that I am posting onto my main page. So what is happening so far is:

Get HTML
POST HTML between div tags
eval javascript
and now innerhtml should change

Thanks in advance!
John
Jun 28 '07 #1
15 7031
rage3324
9 New Member
Just bumping the message up

I am posting html onto my main page between div tags using xmlhttprequest and innerhtml. The html I am posting has javascript inside which I am executing using the eval() function. However, the problem I face is that the javascript uses innerhtml as well and will not work for some reason. I have tested the javascript and it is definitely executing, it just will not change the innerhtml.

To be more clear, the innerhtml is trying to access the html that I am posting onto my main page. So what is happening so far is:

Get HTML
POST HTML between div tags
eval javascript
and now innerhtml should change

Thanks in advance!
John
Jun 28 '07 #2
gits
5,390 Recognized Expert Moderator Expert
hi ...

please give an example on what you are doing ...

you are writing text to a div and this text contains js ... right? now you parse that text and eval the js ... right? the evaled js uses the same text where it is in? ... perhaps you simplify your code and post an example here ... so that we may have a closer look on it.

kind regards ...
Jun 29 '07 #3
rage3324
9 New Member
In my main file where the HTML/JS below is being posted beteween DIV TAGS, there is a script to run the JS after the xmlhttprequest. In the JS below there is a line that needs to access the innerHTML of the element "lg1". However, this will not display on the page. Any ideas?

SHOP.HTML
[HTML]<body>
<link rel="stylesheet " type="text/css" href="screen.cs s" />

<script type="text/javascript">
var s = document.create Element('script ');
s.src = 'yahoo.js';
document.body.a ppendChild(s);
...<execute a few more scripts>
</script>
</body>

<script type="text/javascript">

YAHOO.example.D DApp = function() {
return {
init: function() {
var eul = document.getEle mentById("lg1") ;
var eli = document.create Element("li");
// eli.appendChild (document.creat eTextNode("WSJ. com"));
eli.innerHTML = "<image src='barrons.jp g' />";
eli.id = "test";
eli.setAttribut e("class", "sortList") ;
eli.setAttribut e("className" , "sortList") ;
eli.price = 19.99
eul.appendChild (eli);

new YAHOO.example.D DList("test");

new YAHOO.example.D DListBoundary(" hidden1");
new YAHOO.example.D DListBoundary(" hidden2");
new YAHOO.example.D DListBoundary(" hidden3");
}
};
} ();
YAHOO.util.DDM. mode = YAHOO.util.DDM. INTERSECT; //Sets the mode to Intersect which provides more freedom when dragging and dropping on a target
YAHOO.util.Even t.addListener(w indow, "load", YAHOO.example.D DApp.init);
</script>

<div id="update">
<td>
<ul id="lg1" class="listGrou p1">Products
...
</ul>
</td>
...
</div>
[/HTML]


hi ...

please give an example on what you are doing ...

you are writing text to a div and this text contains js ... right? now you parse that text and eval the js ... right? the evaled js uses the same text where it is in? ... perhaps you simplify your code and post an example here ... so that we may have a closer look on it.

kind regards ...
Jun 29 '07 #4
rage3324
9 New Member
bump up to the top.....
Jun 29 '07 #5
acoder
16,027 Recognized Expert Moderator MVP
<image> is not a valid tag. It should be <img>
Jun 30 '07 #6
gits
5,390 Recognized Expert Moderator Expert
<image> is not a valid tag. It should be <img>
yep ... that is the fatal typo ... i guess ;)
Jul 1 '07 #7
rage3324
9 New Member
Unfortunately that did not make the pictures load :(

Any other ideas?
Jul 2 '07 #8
rage3324
9 New Member
Update.. so I have found that all code inside return { } does not run...

If I run the page as a stand-alone, everything works fine
Jul 2 '07 #9
gits
5,390 Recognized Expert Moderator Expert
and did you resolve your problem?

kind regards ...
Jul 2 '07 #10

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

Similar topics

20
5058
by: Gaz | last post by:
In Internet Explorer 6 I'm having a problem with the httprequest object. I use it to call a webservice and display the result in the readystate event handler. This works the first time I call it but subsequently the readystate event handler function is never called, or the event itself is never fired. The same code works fine in Firefox. Changed it around a lot to no effect Can anyone help? I'm not supposed to create a new...
9
2159
by: Phil_Harvey | last post by:
I am redoing my website and trying to get it to do something more exciting using Javascript. I did normal Java at university and code at work in VB.NET. I have got reasonably far into what I want to do but am having some issues. Firstly I am using an XmlHttpRequest to pull html fragments out of files and wish to put them into the main doccument inplace of a <span></span> which has a given id. The user enters a "command" into a TextField...
6
7300
by: Nathan | last post by:
Can I run two XMLHTTPRequest objects at the same time? Im able to get one to work without problems. If I put a call to a function inside the first ones onreadystatechange function, the 2nd ones readyState is always set to 1 (loading). Ive tried using the same XMLHTTPRequest object, and making a 2nd XMLHTTPRequest object with the same results. Heres my code thats giving me problems... function RefreshChat() {
7
3638
by: pamelafluente | last post by:
The precious input given by Laurent, Martin, Benjamin about XMLHttpRequest in Javascript, has made me think that perhaps I could improve what I am currently doing by using Ajax. Let's make it simple and schematic, to see if there is a simple Ajax answer to this. A. I have an HTML page which has some pure html/css code representing a GRID of cell. The page may also contain other objects (images, etc). B. On the server I have a windows...
1
7710
by: vocalise | last post by:
The title probably isn't very clear, but I haven't been able to find this problem (or I must be having problems figuring out which search strings to use) so I apologize if this has been addressed before, and I apologize if this is the wrong forum since I'm trying to use the XMLHTTPRequest with Javascript and PHP and I couldn't figure out which category my problem belonged to. I am completely new to AJAX and rusty with Javascript. I created a...
1
4036
by: geevaa | last post by:
http://www.phpbuilder.com/columns/kassemi20050606.php3 XMLHttpRequest and AJAX for PHP programmers James Kassemi Introduction: Although the concept isn't entirely new, XMLHttpRequest technology is implemented on more sites now than ever. Compatibility is no longer an issue (IE, Mozilla and Opera all support it), and the benefits to using it are amazing. There are too many PHP programmers avoiding any
20
4049
RMWChaos
by: RMWChaos | last post by:
Currently testing in: WinVista / IE7 I have been working on getting xmlhttprequest going for weeks now. I have finally gotten a semi-working script going. Pulling up text or xml files works great and populates into the webpage; however, executing javascript has a few problems: 1. Opens on a blank page, but not a new page. It appears to compeltely overwrite the original page. I want it to update the existing page by loading within a <div>...
7
1781
RMWChaos
by: RMWChaos | last post by:
Bizarro, that's all I can say. Aren't FF2.0.0.8 and NN9 both Mozilla 2 based browsers? So why would the exact same code work in one and not the other? To add insult to injury, it works just fine in IE7 too. In particular, I'm grabbing a ".txt" file, which you'll see in my code uses innerHTML to display, whereas ".xml" and ".js" files do not. Perhaps not a good way to do it...does NN9 have an issue with innerHTML? So here's my code for all...
2
2451
by: gradinafrica | last post by:
I'm trying to create a log out button that uses AJAX to call a php file which ends the current session: //logout.php <?php if (!session_start()); session_destroy(); //Destroys the session echo "success"; ?>
0
9705
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10567
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10310
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9138
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6847
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5515
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3809
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2983
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.