I have been experimenting with xmlhttprequest. (I am a javascript
newbie, but familiar with programming with VB, Perl, and some PHP.) I
am trying to see if it's possible to receive html snippets back from a
request, and then insert that snippet into the target page; for example,
getting back a set of <ul> lists within lists, or a set of <option>
tags, which could then be added to a page's extent lists, or to select
inputs.
I'm trying to do this by setting the content-type header in the returned
data to text/xml, and I'm able to insert the nodes into the target page;
but then they will not be formatted with any css page I may have set
within the target page. Taking the aforementioned <ul> list, if the
target page references a css page with some layout rules for ul, the
inserted <ul> nodes aren't formatted using these rules.
Here's my code:
if (xmlhttp) {
xmlhttp.open("G ET", "[command]",true);
xmlhttp.onready statechange=fun ction() {
if (xmlhttp.readyS tate==4) {
var insertHere = document.getEle mentById('write root');
var respDoc = xmlhttp.respons eXML;
insertHere.pare ntNode.insertBe fore(respDoc.ch ildNodes
[0].cloneNode(true ),insertHere);
}
}
}
If anyone has any suggestions for a different way to do this, I'd be
very grateful. (I'm trying to do it this simply, that is, just insert
nodes from a request result into the target page. My hope is to avoid
writing extra list-parsing logic on the client side of my app.)
newbie, but familiar with programming with VB, Perl, and some PHP.) I
am trying to see if it's possible to receive html snippets back from a
request, and then insert that snippet into the target page; for example,
getting back a set of <ul> lists within lists, or a set of <option>
tags, which could then be added to a page's extent lists, or to select
inputs.
I'm trying to do this by setting the content-type header in the returned
data to text/xml, and I'm able to insert the nodes into the target page;
but then they will not be formatted with any css page I may have set
within the target page. Taking the aforementioned <ul> list, if the
target page references a css page with some layout rules for ul, the
inserted <ul> nodes aren't formatted using these rules.
Here's my code:
if (xmlhttp) {
xmlhttp.open("G ET", "[command]",true);
xmlhttp.onready statechange=fun ction() {
if (xmlhttp.readyS tate==4) {
var insertHere = document.getEle mentById('write root');
var respDoc = xmlhttp.respons eXML;
insertHere.pare ntNode.insertBe fore(respDoc.ch ildNodes
[0].cloneNode(true ),insertHere);
}
}
}
If anyone has any suggestions for a different way to do this, I'd be
very grateful. (I'm trying to do it this simply, that is, just insert
nodes from a request result into the target page. My hope is to avoid
writing extra list-parsing logic on the client side of my app.)
Comment