Recently, I have been attempting to pick up AJAX and discovered a slight problem with innerHTML..
I have -
<div id='container'></div>
-
then .. -
$('container').innerHTML=req.responseText;
-
The content shows up but when I view source, the <div id='container'> </div> tag shows up as EMPTY, does not input the new content, although the browser displays the ajax reponse in the div, to the user... I assume that innerHTML displays the content directly to the screen but does not update the content between the <div> </div> .. which brings up another problem as my javascript for ajax-in-place-editor references some <div> which was supposed to show up between the <div id='container'> </div> tag ...
What should have been displayed:
eg. -
<div id='container'>
-
<div id='header_1'>hello1</div>
-
<div id='header_2'>hello2</div>
-
<div id='header_3'>hello3</div>
-
</div>
-
instead, it is showing -
<div id='container'></div>
-
as before, and is EMPTY in between those tags (although the browser shows
hello1,hello2,h ello3) but my javascript breaks here, since it cannot find <div id='header_1'> ... and 2, and 3, and so forth..
Any idea how I could solve this problem?
Any help is appreciated! Thanks!
6 5397 Dormilich 8,658
Recognized Expert Moderator Expert
doesn't jquery provide a method for that?
Hi there, thanks for your prompt reply!
hmm actually at the moment I'm using prototype instead of jquery.. would that be a problem in resolving this issue?
Dormilich 8,658
Recognized Expert Moderator Expert
I guess not.
..............
"View Source" does not show any JavaScript generated source (except document.write( ) method in some cases). Firefox Developer Plugin has an option of "View Generated Source", which might help you, otherwise you could always alert(document. getElementById( 'container').in nerHTML); or set it as value to some textarea.
Thanks for your help!
I did read something about putting this into the address bar
javascript:'<xm p>' + window.document .body.outerHTML + '</xmp>'
that will show the javascript generated source as well..
I have solved the bug, so far I realised that javascript that references to the <div> does work, even though it can't see it.. but only after I've used prototype's element update method.. I believe it does something similar to eval() which makes the javascript works ...
However if you only use the conventional
$('show').inner HTML = req.responseTex t;
it will not work as the generated javascript does not run.. so I believe as Dormilich has kindly advised earlier, jQuery and Prototype both have their own update method instead of using the direct $('container'). innerHTML = req.responseTex t method.
Once again, thanks!
You can have firebug addon for Firefox. Using that you can see the dynamic html changes in an element.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Clément |
last post by:
Hi!
I am currently developping a user interface with Ajax/C#/.net. And I am
facing a problem with Mozilla, and Firefox.
I use the function innerHTML to load a Web UserControl into a div, this
way the main page never gets refreshed. It works perfectly under IE,
but with Mozilla and Firefox I got a problem : there is a space before
the thing I want to display everytime I use ".innerHTML".
|
by: tcole6 |
last post by:
My problem appears to be Firefox specific.
I have a hyperlink that loads a new window. This window contains
hyperlinks that call javascript functions in the parent window and then
closes the child window. The function that is called contains an
XMLHttpRequest.
My problem is that everything happens as it should, the innerHTML is
changed by the results of the XMLHttpRequest and the child window
closes. The problem is this, in Firefox,...
|
by: noddy |
last post by:
The full code relating to this question can be found at
http://marc.info/?l=php-general&m=112198633625636&w=2
It describes a bare bones way of making an AJAX request.
It works fine for me except at the last step where data is put into an
innerHTML element within
<div id="foo">
</div>
Here is the function to do that:
|
by: coby |
last post by:
I have an application with a form that has two parts : A & B.
A should be a static form while B shoudl be dynamically loaded via AJAX/PHP.
Using a select box on part A, the onchange event calls an AJAX PHP script that generates PART B (in HTML)
On positive AJAX reply, Part B's HTML is replaced by the returned HTML (using innerHTML)
Works perfect on IE, but not on FF.
On FF, the new form is properly displayed, but when trying to submit...
|
by: Pratik Patel |
last post by:
Hello,
I used innerHTML to assign HTML content. but in my HTML page content
have also some javascript function and it will run when page load. bu
when HTML code assgin thru innerHTML then this javascript is not
working.
e.g.
html content:
| |
by: Tarik Monem |
last post by:
I have been able to successfully retrieve data from an xml file, where the data has been massaged a little bit, to create a table to be retrieved and it is displayed via a document.writeln within a javascript file, but now I am going to go completely AJAX & using innerHTML to display the same information to the browser.
First, snippets of the original code that was working with no problem:
XML first:
<title>bla bla</title>
...
|
by: divyaphilip |
last post by:
Hi,
I have a javascript function that uses ajax to set a div based on a query.
The javascript function is invoked on a button click and uses ajax like this:
function validDate(node,roomid)
{
var allparams= 'timechk=' + params +'&starttime=' +params1 +'&endtime=' + params2 +'&roomid=' + params3 +'&ckres=' + params4
var ajax = new Ajax.Updater(
{success:ck_res},
url,
{method: 'get', parameters:allparams, onFailure: reportError});
|
by: Robin |
last post by:
Martin wrote:
....
You appear to be putting the responseText into DIV 'htmlText' then
'hiddenDiv'. You therefore have two DIVs with id 'divslct4' (not legal
as IDs are supposed to be unique). Your code is changing (and reporting
that state of) the hidden one and hence the visible one isn't changing.
|
by: phub11 |
last post by:
Hi all,
I have started using AJAX to populate drop downs from a mySQL database; however, I want the option of modifying the selected OPTION of the drop down using an array of radiobuttons elsewhere on the page. I have tried...
function updateDrop(sel)
{
alert(document.getElementById('secondDrop').innerHTML);
document.getElementById('secondDrop').innerHTML='<option>'+sel.value+'</option>';
}
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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...
| |
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 captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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();...
|
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...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |