markjohnson123
Programmer
I am just about javascript newbie, so please bear with me!
I have the following code which I use to fetch an external file and place it within a div tag on current page.
At the moment, the code successfully fetches the entire file, but I would like to alter it to fetch only a certain div tag from the file, let's say <div id="mydivtag">
How can I achieve this?
Thanks in advance!
I have the following code which I use to fetch an external file and place it within a div tag on current page.
At the moment, the code successfully fetches the entire file, but I would like to alter it to fetch only a certain div tag from the file, let's say <div id="mydivtag">
How can I achieve this?
Thanks in advance!
Code:
mnmxmlhttp = new myXMLHttpRequest ();
if (mnmxmlhttp) {
mnmxmlhttp.open ("POST", url, true);
mnmxmlhttp.setRequestHeader ('Content-Type',
'application/x-[URL unfurl="true"]www-form-urlencoded');[/URL]
mnmxmlhttp.send (content);
errormatch = new RegExp ("^ERROR:");
target2 = document.getElementById (divcontent);
mnmxmlhttp.onreadystatechange = function () {
if (mnmxmlhttp.readyState == 4) {
mnmString = mnmxmlhttp.responseText;
if (mnmString.match (errormatch)) {
mnmString = mnmString.substring (6, mnmString.length);
target = document.getElementById (divcontent);
target2.innerHTML = mnmString;
} else {
alert(mnmString);
target = document.getElementById (divcontent);
target2.innerHTML = mnmString;
}
}
}
}