Geuis
11-25-2005, 05:37 PM
For some reason, my script is randomly only displaying parts of returned HTML using document.getElementById(update[0]).innerHTML.
I'm setting up a myspace.com style editor for my fiance at http://myspace.thetechgurus.net.
I'm using a slightly modified version of the AJAX script at http://marc.theaimsgroup.com/?l=php-general&m=112198633625636&w=2. My version is at http://myspace.thetechgurus.net/script.js.
I have my php script "action.php" which is receiving the requested myspace account name, accessing that page, and copying back the HTML. It then strips out any <STYLE></STYLE> information and returns the clean version to the AJAX script to display.
If I access the action.php script directly, it returns the full page with no problem. Example: http://myspace.thetechgurus.net/action.php?a=update&data=geuis
However, most of the styling does not load into the DIV when put there by the javascript in script.js using the .innerHTML replacement.
My javascript code is below. Can someone maybe tell me why this isn't working?
/* ##### XMLHttpRequest Code ###################### */
function createRequestObject() {
var ro;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
ro = new ActiveXObject("Microsoft.XMLHTTP");
}else{
ro = new XMLHttpRequest();
}
return ro;
}
var http = createRequestObject();
function sndReq(action,data) {
//send the requested action to action.php, which performs the intemediary handshakes
//with db_functions.php and returns the results
http.open('get', 'action.php?a='+action+'&data='+data);
http.onreadystatechange = handleResponse;
http.send(null);
}
function handleResponse() {
if(http.readyState == 4){
var response = http.responseText;
var id_array = new Array();
var update = new Array();
if(response.indexOf('<&>') != -1) {
//break each id into its own object
id_array = response.split('<&>');
for(var i=0;i<id_array.length-1;i++){
update = id_array[i].split('<|>');
//clear excess spaces from ID name
update[0] = update[0].replace(' ','');
document.getElementById(update[0]).innerHTML = update[1];
}
}
}
}
I'm setting up a myspace.com style editor for my fiance at http://myspace.thetechgurus.net.
I'm using a slightly modified version of the AJAX script at http://marc.theaimsgroup.com/?l=php-general&m=112198633625636&w=2. My version is at http://myspace.thetechgurus.net/script.js.
I have my php script "action.php" which is receiving the requested myspace account name, accessing that page, and copying back the HTML. It then strips out any <STYLE></STYLE> information and returns the clean version to the AJAX script to display.
If I access the action.php script directly, it returns the full page with no problem. Example: http://myspace.thetechgurus.net/action.php?a=update&data=geuis
However, most of the styling does not load into the DIV when put there by the javascript in script.js using the .innerHTML replacement.
My javascript code is below. Can someone maybe tell me why this isn't working?
/* ##### XMLHttpRequest Code ###################### */
function createRequestObject() {
var ro;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
ro = new ActiveXObject("Microsoft.XMLHTTP");
}else{
ro = new XMLHttpRequest();
}
return ro;
}
var http = createRequestObject();
function sndReq(action,data) {
//send the requested action to action.php, which performs the intemediary handshakes
//with db_functions.php and returns the results
http.open('get', 'action.php?a='+action+'&data='+data);
http.onreadystatechange = handleResponse;
http.send(null);
}
function handleResponse() {
if(http.readyState == 4){
var response = http.responseText;
var id_array = new Array();
var update = new Array();
if(response.indexOf('<&>') != -1) {
//break each id into its own object
id_array = response.split('<&>');
for(var i=0;i<id_array.length-1;i++){
update = id_array[i].split('<|>');
//clear excess spaces from ID name
update[0] = update[0].replace(' ','');
document.getElementById(update[0]).innerHTML = update[1];
}
}
}
}