I'm having issues with setting up a function that executes an ajax statement within, but doesn't go past it, to return false.
Example Ajax function:
My separate function:
And this is a sample link:
What this code is supposed to do is open a new window with the given URL and re-load some information in the current window with the AJAX script.
What it ends up doing is Opening the new window, reloading my content, and then opening another window (using target _blank) just like the return false didn't even work.
Is there something wrong? Why is it not getting past my AJAX method?
This might help: I'm constantly getting this error in my Error Console:
Error: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIXMLHttpRequest.send]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: :: myAjax :: line 148" data: no]
(Line 148 being: xmlhttp.send('')
I don't know what it means. I had to put it in there because it wasn't working in some browser... I can't remember which, maybe IE or Safari.
_______________
_brian.
Example Ajax function:
Code:
function myAjax(url,method,id){
var xmlhttp=false;
try {
xmlhttp = new ActiveXObject('Msxml2.XMLHTTP');
}
catch (e) {
try {
xmlhttp = new
ActiveXObject('Microsoft.XMLHTTP');
}
catch (E) {
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest();
}
xmlhttp.open(method, url, true);
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==1) {
document.getElementById('status').style.display = '';
}
if (xmlhttp.readyState==4) {
document.getElementById('status').style.display = 'none';
var content = xmlhttp.responseText;
if( content ){
document.getElementById(id).innerHTML = content;
}
}
}
xmlhttp.send(null);
xmlhttp.send('');
return;
}
Code:
function loadItUp(fileid){
NewWindow('go.php?doc='+fileid,'document'+fileid,'500','380','no','center');
refreshDocuments();
return false;
}
function refreshDocuments(){
myAjax('do.php?docs','GET','doclist');
}
Code:
<a href="go.php?doc=6" target="_blank" onClick="return loadItUp('6');">open doc 6</a>
What this code is supposed to do is open a new window with the given URL and re-load some information in the current window with the AJAX script.
What it ends up doing is Opening the new window, reloading my content, and then opening another window (using target _blank) just like the return false didn't even work.
Is there something wrong? Why is it not getting past my AJAX method?
This might help: I'm constantly getting this error in my Error Console:
Error: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIXMLHttpRequest.send]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: :: myAjax :: line 148" data: no]
(Line 148 being: xmlhttp.send('')
I don't know what it means. I had to put it in there because it wasn't working in some browser... I can't remember which, maybe IE or Safari.
_______________
_brian.