0

My code is in the attachment alex.txt.

When i press the button for first time it gives me error: 'null' is null or not an object. But when i press it again or refresh the page and press the button it gives me the result that i expect.

When i change the var pdbfile1,2,3 values(for example with 2x4n;3gis;1crn) and press the button again there is the error again and i have to refresh the page again.

Can you please help me to to resolve this problem.

Attachments
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>

<script type="text/javascript">
document.write("<input type='checkbox' id='option4'  value='pw_fatcat' onclick='pairwise(1);'>jFatCat_rigid<br>");

function pairwise(checkbox) {
//Izxiskva se trusted sites i Miscellaneous > Access Data across domains > Enable.
		
var action='pw_fatcat';
var pdbfile='2x4n'; //this is what i change
	var pdbfile1='3gys';
	var pdbfile2='a';
	var pdbfile3='a';
	
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
				
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		
		if(ajaxRequest.readyState == 4 && ajaxRequest.status == 200){
			var xmlDoc = ajaxRequest.responseXML;
			
				var x=xmlDoc.getElementsByTagName("AFPChain")[0]; 
 				document.write(x.getAttribute("ca1Length")); 
 				   						
		}
			}
	
	ajaxRequest.open("GET","http://www.pdb.org/pdb/workbench/getaligned.do?action="+action+"&pdb1="+pdbfile+"&chain1="+pdbfile2+"&pdb2="+pdbfile1+"&chain2="+pdbfile3+"&type=xml",true);
	
	ajaxRequest.send(); 
	
}
</script>
</body>
</html>
2
Contributors
7
Replies
9
Views
7 Years
Discussion Span
Last Post by fxm
0

The code you posted returns the file you want

<AFPChain name1="2X4N.a" name2="3GYS.a" method="jFatCat_rigid" version="1.0" alnLength="187" blockNum="1" ... etc.

but Firefox reports

XML Parsing Error: no element found Location: moz-nullprincipal:{7ecb1187-1a21-4b63-bbc6-5b638a8a46d7} Line Number 1, Column 1:

^

The error 'null' is null or not an object may be the result of that or it may be something completely different; I can't tell without seeing more of the code.

0

IE8 is more forgiving.
It retrieves and parses the XML file without error, then writes 275 (the value of 'ca1Length') as expected.

0

Thank you so much for spending your time for me.

I'm using IE8 and it is still not working. Here is my all code. But please try puting different data for pdb1 and pdb 2 as
pdb1:3gys or "3D4X" or "3gis"
chain:a

pdb2:2x4n or "2QU0" or "1crn"
chain:a

and you will see that at first is not working and giving the error but when you click and unclick it will give the result.

Attachments
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<script type="text/javascript" src="jmol/Jmol.js"></script>


<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" ;/>
<title></title>
</head>
<body>


<script language="javascript" type="text/javascript">


	function ajaxFunction1(z){
	var ajaxRequest1;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest1 = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest1 = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest1 = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	
		var t=z;
		
		
	// Create a function that will receive data sent from the server
	ajaxRequest1.onreadystatechange = function(){
		
		if(ajaxRequest1.readyState == 4){
			document.getElementById(t).innerHTML = ajaxRequest1.responseText;
			
	}

	}
	var wb_action = workbenchaction;
	var wb_pdb1 = document.getElementById('workbenchPDB1').value;
	var wb_chain1 = document.getElementById('workbenchChain1').value;
	var wb_pdb2 = document.getElementById('workbenchPDB2').value;
	var wb_chain2 = document.getElementById('workbenchChain2').value;
	var wb_url = "http://www.rcsb.org/pdb/workbench/workbench.do?action="+wb_action+"&mol="+wb_pdb1+"."+wb_chain1+"&mol="+wb_pdb2+"."+wb_chain2;
	
	var pdbfile=encodeURIComponent(document.getElementById("workbenchPDB1").value);
	var pdbfile1=encodeURIComponent(document.getElementById("workbenchPDB2").value);
	var pdbfile2=encodeURIComponent(document.getElementById("workbenchChain1").value);
	var pdbfile3=encodeURIComponent(document.getElementById("workbenchChain2").value);	
	
	
	
	ajaxRequest1.open("GET", "deleteme.php?wb_url="+wb_url+"&workbenchPDB1="+pdbfile+"&workbenchChain1="+pdbfile2+"&workbenchPDB2="+pdbfile1+"&workbenchChain2="+pdbfile3, true);
	ajaxRequest1.send(null); 
}


document.write("<div  align='center' style='width:32.3%; float:left; padding-top:5px; height:140px;   border:1px solid black; '>");
document.write("PDB1: <input type='text' name='workbenchPDB1' id='workbenchPDB1' size='4' maxlength='4'/>");
document.write("Chain: <input type='text' name='workbenchChain1' id='workbenchChain1' size='4' maxlength='1'>");
document.write("</div>");
document.write("<div  style='width:33%;height:145px; float:left;padding-left:6px;  border:1px solid black; '>");
document.write("<div align='left' style='width:49%;  height:145px; padding-left:4px;  float:left;  '>");
document.write("<div align='left' style='width:49%; height:145px;    float:right;   '>");
document.write("<input type='checkbox' id='option4'  value='pw_fatcat' onclick='pairwise(1);'>jFatCat_rigid<br>");
document.write("</div>");
document.write("<div align='center' style='width:33%; float:left; height:140px;  border:1px solid black;padding-top:5px; '>");
document.write("PDB2: <input type='text' name='workbenchPDB2'  id='workbenchPDB2' size='4' maxlength='4'/>");
document.write("Chain: <input type='text' name='workbenchChain2' id='workbenchChain2' size='4' maxlength='1'/>");
document.write("</div>");
document.close();
</script>


<div id='hide0'></div>

<div id='hide1' style="width:49%; float:left; background-color: #0C6"></div>

<div id='hide2' style="width:49%; float:left;  background-color: #F96"></div>

<div id='hide3' style="width:49%; float:left; background-color: #CF6"></div>

<div id='test' style=" width:49%;  float:left;"></div>

<div id='hide4' style=" width:100%;  float:left;">
<br />
<table align="center" style="text-align:center" id="alex">
<tr>
<td style="text-align:center" id='head'></td>
</tr>
<tr id="zaglavie" style="visibility:hidden";>
<td style="text-align:center">Structure alignment method</td>
<td style="text-align:center">P-value</td>
<td style="text-align:center">Equ</td>
<td style="text-align:center">RMSD</td>
<td style="text-align:center">Score</td>
<td style="text-align:center">Align-len</td>
<td style="text-align:center">Gaps</td>
<td style="text-align:center">Identity</td>
<td style="text-align:center">Similarity</td>
</tr>
<tr >
<td id='method'></td>
<td id='p_value'></td>
<td id='equ'></td>
<td id='rmsd'></td>
<td id='score'></td>
<td id='align-len'></td>
<td id='gaps'></td>
<td id='identity'></td>
<td id='similarity'></td>
</tr>

</table>
</div>



<script type="text/javascript">

 
function deleterow(z){
var row = document.getElementById(z);
row.parentElement.removeChild(row); 
}

function pairwise(checkbox) {
//Izxiskva se trusted sites i Miscellaneous > Access Data across domains > Enable.
	
var action;



if (checkbox=='1') {if (document.getElementById('option4').checked == true) {action = document.getElementById('option4').value}
					 else {deleterow(document.getElementById('option4').value);return false;}
				   }
else if (checkbox=='2')
				   {if (document.getElementById('option5').checked == true) {action = document.getElementById('option5').value}
					 else {deleterow(document.getElementById('option5').value);return false;}
				   }
else if (checkbox=='3')
				   {if (document.getElementById('option6').checked == true) {action = document.getElementById('option6').value}
					 else {deleterow(document.getElementById('option6').value);return false;}
				   }
else if (checkbox=='4')
				   {if (document.getElementById('option7').checked == true) {action = document.getElementById('option7').value}
					 else {deleterow(document.getElementById('option7').value);return false;}
				   }
else return false;

	var pdbfile=encodeURIComponent(document.getElementById("workbenchPDB1").value);
	var pdbfile1=encodeURIComponent(document.getElementById("workbenchPDB2").value);
	var pdbfile2=encodeURIComponent(document.getElementById("workbenchChain1").value);
	var pdbfile3=encodeURIComponent(document.getElementById("workbenchChain2").value);	
	
	
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	
			
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		
		if(ajaxRequest.readyState == 4 && ajaxRequest.status == 200){
			var xmlDoc = ajaxRequest.responseXML;
			
				var x=xmlDoc.getElementsByTagName("AFPChain")[0]; 
  var length_pdb1=x.getAttribute("ca1Length"); 
  var length_pdb2=x.getAttribute("ca2Length"); 
 document.getElementById('head').innerHTML='Structure Alignment Results for '+pdbfile+'.'+pdbfile2+' length:'+length_pdb1+' vs. '+pdbfile1+'.'+pdbfile3 +' length:'+length_pdb2; 
 
  var body = document.getElementsByTagName("body")[0];
  

        // creates a <table> element and a <tbody> element
        var tbl     = document.getElementById("alex");
        var tblBody = document.createElement("tbody");

        // creating all cells
		var a=new Array(); 
      a[0]=x.getAttribute("method");
 a[1]=x.getAttribute("probability");
 a[2]=x.getAttribute("similarity2");
 a[3]=x.getAttribute("totalRmsdOpt");
 a[4]=x.getAttribute("alignScore");
 a[5]=x.getAttribute("alnLength");
 a[6]=x.getAttribute("gapLen");
 a[7]=x.getAttribute("identity")*100;
 a[8]=x.getAttribute("similarity")*100;
 
  
            var row = document.createElement("tr");
			row.setAttribute("id",action); 
			row.setAttribute("bgcolor","cyan");

            for (var i = 0; i < 9; i++) {
			
                // Create a <td> element and a text node, make the text
                // node the contents of the <td>, and put the <td> at
                // the end of the table row
                var cell = document.createElement("td");
                var cellText = document.createTextNode(a[i]);
                cell.appendChild(cellText);
                row.appendChild(cell);
			}

            // add the row to the end of the table body
            tblBody.appendChild(row);
        		
        // put the <tbody> in the <table>
        tbl.appendChild(tblBody);
        // appends <table> into <body>
        body.appendChild(tbl);
        // sets the border attribute of tbl to 2;
        tbl.setAttribute("border", "2");
    		
		   		
		}
		else	
         {
         //   alert("Error: returned status code " + ajaxRequest.status);
         }	

	}
	
	ajaxRequest.open("GET","http://www.pdb.org/pdb/workbench/getaligned.do?action="+action+"&pdb1="+pdbfile+"&chain1="+pdbfile2+"&pdb2="+pdbfile1+"&chain2="+pdbfile3+"&type=xml",true);
	ajaxRequest.send(); 
}
</script>





</body>
</html>
0

To test here I would need
<script src="jmol/Jmol.js" type="text/javascript"></script>
and anything similar that is included in the page .

0

and this is the deleteme.php /which is not so important/

Attachments
<?php
$url=$_GET['wb_url'];

$a='&mol=';
$dot='.';
$p=htmlspecialchars($_GET['workbenchPDB1']);
$p1=htmlspecialchars($_GET['workbenchPDB2']);
$p2=htmlspecialchars($_GET['workbenchChain1']);
$p3=htmlspecialchars($_GET['workbenchChain2']);
$url=$url.$a.$p.$dot.$p2.$a.$p1.$dot.$p3;
//echo $url;
$str = file_get_contents($url);



$example = substr($str,strpos($str,'Text Representation '));

echo $example = str_replace(substr($example,strpos($example,'Acknowledgements')), '',$example);

 

?>
0

Provided that the values 2X4N:a 3GYS:a are entered before the checkbox is clicked, this version of test page

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>


<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" ;/>
<title></title>
</head>
<body>


<script language="javascript" type="text/javascript">


	function ajaxFunction1(z){
	var ajaxRequest1;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest1 = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest1 = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest1 = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	
		var t=z;
		
		
	// Create a function that will receive data sent from the server
	ajaxRequest1.onreadystatechange = function(){
		
		if(ajaxRequest1.readyState == 4){
			document.getElementById(t).innerHTML = ajaxRequest1.responseText;
			
	}

	}
	var wb_action = workbenchaction;
	var wb_pdb1 = document.getElementById('workbenchPDB1').value;
	var wb_chain1 = document.getElementById('workbenchChain1').value;
	var wb_pdb2 = document.getElementById('workbenchPDB2').value;
	var wb_chain2 = document.getElementById('workbenchChain2').value;
	var wb_url = "http://www.rcsb.org/pdb/workbench/workbench.do?action="+wb_action+"&mol="+wb_pdb1+"."+wb_chain1+"&mol="+wb_pdb2+"."+wb_chain2;
	
	var pdbfile=encodeURIComponent(document.getElementById("workbenchPDB1").value);
	var pdbfile1=encodeURIComponent(document.getElementById("workbenchPDB2").value);
	var pdbfile2=encodeURIComponent(document.getElementById("workbenchChain1").value);
	var pdbfile3=encodeURIComponent(document.getElementById("workbenchChain2").value);	
	
	
	
	ajaxRequest1.open("GET", "deleteme.php?wb_url="+wb_url+"&workbenchPDB1="+pdbfile+"&workbenchChain1="+pdbfile2+"&workbenchPDB2="+pdbfile1+"&workbenchChain2="+pdbfile3, true);
	ajaxRequest1.send(null); 
}


document.write("<div  align='center' style='width:32.3%; float:left; padding-top:5px; height:140px;   border:1px solid black; '>");
document.write("PDB1: <input type='text' name='workbenchPDB1' id='workbenchPDB1' size='4' maxlength='4'/>");
document.write("Chain: <input type='text' name='workbenchChain1' id='workbenchChain1' size='4' maxlength='1'>");
document.write("</div>");
document.write("<div  style='width:33%;height:145px; float:left;padding-left:6px;  border:1px solid black; '>");
document.write("<div align='left' style='width:49%;  height:145px; padding-left:4px;  float:left;  '>");
document.write("<div align='left' style='width:49%; height:145px;    float:right;   '>");
document.write("<input type='checkbox' id='option4'  value='pw_fatcat' onclick='pairwise(1);'>jFatCat_rigid<br>");
document.write("</div>");
document.write("<div align='center' style='width:33%; float:left; height:140px;  border:1px solid black;padding-top:5px; '>");
document.write("PDB2: <input type='text' name='workbenchPDB2'  id='workbenchPDB2' size='4' maxlength='4'/>");
document.write("Chain: <input type='text' name='workbenchChain2' id='workbenchChain2' size='4' maxlength='1'/>");
document.write("</div>");
document.close();
</script>


<div id='hide0'></div>

<div id='hide1' style="width:49%; float:left; background-color: #0C6"></div>

<div id='hide2' style="width:49%; float:left;  background-color: #F96"></div>

<div id='hide3' style="width:49%; float:left; background-color: #CF6"></div>

<div id='test' style=" width:49%;  float:left;"></div>

<div id='hide4' style=" width:100%;  float:left;">
<br />
<table align="center" style="text-align:center" id="alex">
<tr>
<td style="text-align:center" id='head'></td>
</tr>
<tr id="zaglavie" style="visibility:hidden";>
<td style="text-align:center">Structure alignment method</td>
<td style="text-align:center">P-value</td>
<td style="text-align:center">Equ</td>
<td style="text-align:center">RMSD</td>
<td style="text-align:center">Score</td>
<td style="text-align:center">Align-len</td>
<td style="text-align:center">Gaps</td>
<td style="text-align:center">Identity</td>
<td style="text-align:center">Similarity</td>
</tr>
<tr >
<td id='method'></td>
<td id='p_value'></td>
<td id='equ'></td>
<td id='rmsd'></td>
<td id='score'></td>
<td id='align-len'></td>
<td id='gaps'></td>
<td id='identity'></td>
<td id='similarity'></td>
</tr>

</table>
</div>



<script type="text/javascript">

 
function deleterow(z){
var row = document.getElementById(z);
row.parentElement.removeChild(row); 
}

function pairwise(checkbox) {
//Izxiskva se trusted sites i Miscellaneous > Access Data across domains > Enable.
	
var action;

if (checkbox == '1') {
    if (document.getElementById('option4').checked == true) {
        action = document.getElementById('option4').value
    }
    else {
        deleterow(document.getElementById('option4').value);
        return false;
    }
}
else if (checkbox == '2') {
    if (document.getElementById('option5').checked == true) {
        action = document.getElementById('option5').value
    }
    else {
        deleterow(document.getElementById('option5').value);
        return false;
    }
}
else if (checkbox == '3') {
    if (document.getElementById('option6').checked == true) {
        action = document.getElementById('option6').value
    }
    else {
        deleterow(document.getElementById('option6').value);
        return false;
    }
}
else if (checkbox == '4') {
    if (document.getElementById('option7').checked == true) {
        action = document.getElementById('option7').value
    }
    else {
        deleterow(document.getElementById('option7').value);
        return false;
    }
}
else return false;

var pdbfile = encodeURIComponent(document.getElementById("workbenchPDB1").value);
var pdbfile1 = encodeURIComponent(document.getElementById("workbenchPDB2").value);
var pdbfile2 = encodeURIComponent(document.getElementById("workbenchChain1").value);
var pdbfile3 = encodeURIComponent(document.getElementById("workbenchChain2").value);

var ajaxRequest; // The variable that makes Ajax possible!
try {
    // Opera 8.0+, Firefox, Safari
    ajaxRequest = new XMLHttpRequest();
} catch (e) {
    // Internet Explorer Browsers
    try {
        ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
        try {
            ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
            // Something went wrong
            alert("Your browser broke!");
            return false;
        }
    }
}

// Create a function that will receive data sent from the server

ajaxRequest.onreadystatechange = function () {
    if (ajaxRequest.readyState == 4 && ajaxRequest.status == 200) {
        var xmlDoc = ajaxRequest.responseXML;
        var x = xmlDoc.getElementsByTagName("AFPChain")[0];

        var length_pdb1 = x.getAttribute("ca1Length");
        var length_pdb2 = x.getAttribute("ca2Length");

        document.getElementById('head').innerHTML = 'Structure Alignment Results for ' + pdbfile + '.' + pdbfile2 + ' length:' + length_pdb1 + ' vs. ' + pdbfile1 + '.' + pdbfile3 + ' length:' + length_pdb2;

        var body = document.getElementsByTagName("body")[0];

        // creates a <table> element and a <tbody> element
        var tbl = document.getElementById("alex");
        var tblBody = document.createElement("tbody");

        var row = document.createElement("tr");
        row.setAttribute("id", action);
        row.setAttribute("bgcolor", "cyan");

        // creating all cells
        var a = new Array();
        a[0] = x.getAttribute("method");
        a[1] = x.getAttribute("probability");
        a[2] = x.getAttribute("similarity2");
        a[3] = x.getAttribute("totalRmsdOpt");
        a[4] = x.getAttribute("alignScore");
        a[5] = x.getAttribute("alnLength");
        a[6] = x.getAttribute("gapLen");
        a[7] = x.getAttribute("identity") * 100;
        a[8] = x.getAttribute("similarity") * 100;
        for (var i = 0; i < 9; i++) {
            // Create a <td> element and a text node, make the text
            // node the contents of the <td>, and put the <td> at
            // the end of the table row
            var cell = document.createElement("td");
            var cellText = document.createTextNode(a[i]);
            cell.appendChild(cellText);
            row.appendChild(cell);
        }
        // add the row to the end of the table body
        tblBody.appendChild(row);
        // put the <tbody> in the <table>
        tbl.appendChild(tblBody);
        // appends <table> into <body>
        body.appendChild(tbl);
        // sets the border attribute of tbl to 2;
        tbl.setAttribute("border", "2");
    }
    else {
        //   alert("Error: returned status code " + ajaxRequest.status);
    }
}

ajaxRequest.open("GET", "http://www.pdb.org/pdb/workbench/getaligned.do?action=" + action + "&pdb1=" + pdbfile + "&chain1=" + pdbfile2 + "&pdb2=" + pdbfile1 + "&chain2=" + pdbfile3 + "&type=xml", true);

ajaxRequest.send();
}
</script>

</body>
</html>

returns what appear to be the desired values in a cyan row.

Do you get a different result?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.