Solved

Javascript Error in MSXML2.XMLHTTP.3.0

Posted on 2007-11-21
6
388 Views
Last Modified: 2010-08-05
Dear Expert,

I created a market value listening apllication with using ajax concept. and hosted in a server
http://www.princesscar.com/55.asp
this code is not working in all pc after clicking start button i am getting javascript error
Permission denied. but in my PC it is working fine.
Please help me with alternate code wich meet same requirement
My code is attached with this

File No:1
File Name: 55.asp
 
 
 
<html>
 
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Symbol</title>
</head>
 
<body>
 
 <%
Set objXML = Server.CreateObject("MSXML2.ServerXMLHTTP.4.0")
 
url="http://194.170.200.66/Ticker?sql=select%20'<root>';select+*+from+MWA_NormalLotWatch+FOR+XML+auto;select%20'</root>'"
response.Write(url)
 
 
 
 
Dim objXMLHTTP, sResponseText
Set objXMLHTTP = Server.CreateObject("Msxml2.ServerXMLHTTP.4.0")
 
objXMLHTTP.open "GET",url, false
objXMLHTTP.send 
sResponseText = objXMLHTTP.responseText 
 
 
 
 
 
 
 
 
 
 
MasterSplit ="<MWA_NormalLotWatch SECode"
SubSplit=chr(34)
 
a=Split(sResponseText,MasterSplit )
set objXMLHTTP = nothing
 
Dim sArray ' Declare your variant for the array 
Dim Grid
Dim nCur 
Dim nNewTot 
 
 
 
' Dimension the array into 2 dimensions 
 
Redim sArray(100,22) 
 
int ArrayCount
ArrayCount=0
Redim sArray(UBound(a),1000) 
Redim Grid(UBound(a),15) 
 
for i = 1 to UBound(a) 
Outx= Replace(a(i), chr(34), "")
Outx="Market" & Replace(Outx, "=", " ")
 
 
 b=Split(Outx," ")
 ArrayCount=0
  	For j= 0 to UBound(b)  
  			ArrayCount=ArrayCount+1
	   		sArray(i,j)=b(j)
	    	 
	   			
	   			Select case b(j)
	   				case "SecCode"
	   					Grid(i,0)=b(j+1)
	   				case "LastClosePrice"
	   					Grid(i,1)=b(j+1)
	   				case "AvgPrice"
	   					Grid(i,2)=b(j+1)
	   				case "PercentageChange"
	   					Grid(i,3)=b(j+1)
	   				case "LastClosePrice"
	   					Grid(i,4)=b(j+1)
	   				case "BidQty"
	   					Grid(i,5)=b(j+1)
	   				case "BidPrice"
	   					Grid(i,6)=b(j+1)
	   				case "AskPrice"
	   					Grid(i,7)=b(j+1)
	   				case "AskQty"
	   					Grid(i,8)=b(j+1)
	   				case "TotalTrades"
	   					Grid(i,9)=b(j+1)
	   				case "TotalVolume"
	   					Grid(i,10)=b(j+1)
	   				case "TotalValue"	
	   					Grid(i,11)=b(j+1)
	   				case "High52"
	   					Grid(i,12)=b(j+1)
	   				case "Low52"
	   					Grid(i,13)=b(j+1)
	   				
	 
	   			End Select 
	   		
  	Next 
  	
   
 
  
next 
 
 
 
%>
<html>
 <body>
<form method="POST" action="--WEBBOT-SELF--">
	<!--webbot bot="SaveResults" U-File="D:\Documents and Settings\Administrator.RAJ\Desktop\_private\form_results.csv" S-Format="TEXT/CSV" S-Label-Fields="TRUE" startspan --><strong>[FrontPage Save Results Component]</strong><!--webbot bot="SaveResults" i-checksum="6561" endspan -->
	<p>&nbsp;</p>
</form>
<table border="1" style="border-collapse: collapse" width="100%" id="table1">
	<tr>
		<td width="82"><b><font face="Arial" size="2">Symbol</font></b></td>
		<td width="97"><b><font face="Arial" size="2">Last Close Price</font></b></td>
		<td width="102"><b><font face="Arial" size="2">Current Avg Price</font></b></td>
		<td width="85"><b><font face="Arial" size="2">Change</font></b></td>
		<td width="61"><b><font face="Arial" size="2">Last Price</font></b></td>
		<td width="72"><b><font face="Arial" size="2">Bid Volume</font></b></td>
		<td width="56"><b><font face="Arial" size="2">Bid Price</font></b></td>
		<td width="60"><b><font face="Arial" size="2">Ask Price</font></b></td>
		<td width="76"><b><font face="Arial" size="2">Ask Volume</font></b></td>
		<td width="66"><b><font face="Arial" size="2">Total trade</font></b></td>
		<td width="76"><b><font face="Arial" size="2">Total Volume</font></b></td>
		<td><b><font face="Arial" size="2">Total Value</font></b></td>
		<td><b><font face="Arial" size="2">High Price</font></b></td>
		<td><b><font face="Arial" size="2">Low Price</font></b></td>
	</tr>
	<%
	for i = 0 to UBound(a)
	%>	
	<tr>
		<td id="0_<%=i%>" width="82"> <%=Grid(i,0)%></font></td>
		<td id="1_<%=i%>" width="97"> <%=Grid(i,1)%></font></td>
		<td id="2_<%=i%>" width="102"> <%=Grid(i,2)%></font></td>
		<td id="3_<%=i%>" width="85"> <%=Grid(i,3)%></font></td>
		<td id="4_<%=i%>" width="61"> <%=Grid(i,4)%></font></td>
		<td id="5_<%=i%>" width="72"> <%=Grid(i,5)%></font></td>
		<td id="6_<%=i%>" width="56"> <%=Grid(i,6)%></font></td>
		<td id="7_<%=i%>" width="60"> <%=Grid(i,7)%></font></td>
		<td id="8_<%=i%>" width="76"> <%=Grid(i,8)%></font></td>
		<td id="9_<%=i%>" width="66">  <%=Grid(i,9)%></font></td>
		<td id="10_<%=i%>" width="76"> <%=Grid(i,10)%></font></td>
		<td id="11_<%=i%>">  <%=Grid(i,11)%></font></td>
		<td id="12_<%=i%>"> <%=Grid(i,12)%></font></td>
		<td id="13_<%=i%>"> <%=Grid(i,13)%></font></td>
	</tr>
	<%
	Next
	%>
</table>
<script language="javascript">
 
var xmlHttp
var memdata=new Array(14)
var memcellcol=new Array(14)
 
 
function showHint(argc)
{
 
 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
} 
 
 
 
 
 
 
//var myurl ="http://princesscar.com/temp.asp" 
var myurl ="http://194.170.200.66/Ticker?sql=select%20'<root>';select+*+from+MWA_NormalLotWatch+FOR+XML+auto;select%20'</root>'"
 
xmlHttp.onreadystatechange=stateChanged 
 
xmlHttp.open("GET",myurl,true)
xmlHttp.send(null)
 
} 
 
 
function GetColRadeiant(Ratio,r1,g1,b1,r2,g2,b2)
{
	var tr=r2 + ((r1-r2)*Ratio);
	var tg=g2 + ((g1-g2)*Ratio);
	var tb=b2 + ((b1-b2)*Ratio);
	return "rgb(" + tr + "," + tg + "," + tb + ")";
}
 
function stateChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
 	 	var Symb=xmlHttp.responseText ;
 	 	var Symb_row=Symb.split("*");
	  	var i =0 ;
 		while (i < Symb_row.length)
		{
  			var RowData=Symb_row[i];
    		var symb_Field=RowData.split("|");
   			var j=0;
 			while(j < symb_Field.length-1)
 			{
 
 				var cellName= j + "_" + (i + 1);
 				if(memdata[j][i] != symb_Field[j])
 				{
 					
					
					if(memdata[j][i] != "~")
					{
						
						document.getElementById(cellName).innerHTML= symb_Field[j];
						memcellcol[j][i]=11;
					}
 					memdata[j][i]=symb_Field[j];
 
 				}
 				
 				
 				if(memcellcol[j][i] >0)
 				{
 					memcellcol[j][i]--;
						document.getElementById(cellName).style.backgroundColor = GetColRadeiant(memcellcol[j][i]/10,255,105,180,255,255,255);      //"#FF6699";
 				}
 				j++;
 			}    		
   		 	i++ ;
   		}
	  	timerID = setTimeout("UpdateTimer()", 1000);
	 } 
} 
 
function GetXmlHttpObject()
{ 
var objXMLHttp=null
if (window.XMLHttpRequest)
{
objXMLHttp=new XMLHttpRequest()
}
else if (window.ActiveXObject)
{
objXMLHttp=new ActiveXObject('MSXML2.XMLHTTP.3.0')
 
 
  
}
return objXMLHttp
} 
 
 
 
 
 
 
 
<!--
// please keep these lines on when you copy the source
// made by: Nicolas - http://www.javascript-page.com
 
var timerID = 0;
var tStart  = null;
 
function UpdateTimer() {
   if(timerID) {
      clearTimeout(timerID);
      clockID  = 0;
   }
 
   if(!tStart)
      tStart   = new Date();
 
   var   tDate = new Date();
   var   tDiff = tDate.getTime() - tStart.getTime();
 
   tDate.setTime(tDiff);
 
   document.theTimer.theTime.value =   tDate.getSeconds();
 
   showHint(document.theTimer.theTime.value)
   
}
 
function Start() {
	var i=0 ;
 	while (i <=14)
 	{
   		memdata[i]= new Array(document.theTimer.txtcol.value + 1 );
   		memcellcol[i]= new Array(document.theTimer.txtcol.value + 1 );
   		
   		var j=0;
   		while (j<document.theTimer.txtcol.value)
   		{
   			memdata[i][j]="~";
   			memcellcol[i][j]=0;
   			j++;
   		}
   		i++ ;
  	}
   	tStart   = new Date();
   	document.theTimer.theTime.value = "00:00";
   	timerID  = setTimeout("UpdateTimer()", 1000);
}
 
function Stop() {
   if(timerID) {
      clearTimeout(timerID);
      timerID  = 0;
   }
 
   tStart = null;
}
 
function Reset() {
   tStart = null;
 
   document.theTimer.theTime.value = "00:00";
}
 
//-->
 
 
 
	
 
 
</script>
 
<p><a href="javascript:showHint();">Change</a></p>
 
</body>
<body onload="Reset()" onunload="Stop()">
<center><form name="theTimer"><table>
   <tr>
      <td colspan=3 align=center>
         <input type=text name="theTime" size=5>&nbsp;
         <input type=text name="txtcol" size=5 value="<% =UBound(a) %>">
         <input type=text name="cbx" size=73></td>
   </tr>
   <tr><td></td></tr>
   <tr>
      <td>
         <input type=button name="start" value="Start" onclick="Start()">
      </td>
      <td>
         <input type=button name="stop" value="Stop" onclick="Stop()">
      </td>
      <td>
         <input type=button name="reset" value="Reset" onclick="Reset()">
      </td>
   </tr>
</table>
	<p>
         </p>
</form> 
<p><font color="#008000">dddd</font></p>
 
</html>
File No:2
File Name: temp.asp
 
<%
 
Set objXML = Server.CreateObject("MSXML2.ServerXMLHTTP.4.0")
 
url="http://194.170.200.66/Ticker?sql=select%20'<root>';select+*+from+MWA_NormalLotWatch+FOR+XML+auto;select%20'</root>'"
 
 
 
 
 
Dim objXMLHTTP, sResponseText
Set objXMLHTTP = Server.CreateObject("Msxml2.ServerXMLHTTP.4.0")
 
objXMLHTTP.open "GET",url, false
objXMLHTTP.send 
sResponseText = objXMLHTTP.responseText 
 
 
 
 
 
 
 
 
 
 
MasterSplit ="<MWA_NormalLotWatch SECode"
SubSplit=chr(34)
 
a=Split(sResponseText,MasterSplit )
set objXMLHTTP = nothing
 
Dim sArray ' Declare your variant for the array 
Dim Grid
Dim nCur 
Dim nNewTot 
 
 
 
' Dimension the array into 2 dimensions 
 
Redim sArray(100,22) 
 
int ArrayCount
ArrayCount=0
Redim sArray(UBound(a),100) 
Redim Grid(UBound(a),15) 
 
for i = 1 to UBound(a) 
Outx= Replace(a(i), chr(34), "")
Outx="Market" & Replace(Outx, "=", " ")
 
 
 b=Split(Outx," ")
 ArrayCount=0
  	For j= 0 to UBound(b)  
  			ArrayCount=ArrayCount+1
	   		sArray(i,j)=b(j)
	    	 
	   			
	   			Select case b(j)
	   				case "SecCode"
	   					Grid(i,0)=b(j+1)
	   				case "LastClosePrice"
	   					Grid(i,1)=b(j+1)
	   				case "AvgPrice"
	   					Grid(i,2)=b(j+1)
	   				case "PercentageChange"
	   					Grid(i,3)=b(j+1)
	   				case "LastClosePrice"
	   					Grid(i,4)=b(j+1)
	   				case "BidQty"
	   					Grid(i,5)=b(j+1)
	   				case "BidPrice"
	   					Grid(i,6)=b(j+1)
	   				case "AskPrice"
	   					Grid(i,7)=b(j+1)
	   				case "AskQty"
	   					Grid(i,8)=b(j+1)
	   				case "TotalTrades"
	   					Grid(i,9)=b(j+1)     
	   				case "TotalVolume"
	   					Grid(i,10)=b(j+1)
	   				case "TotalValue"	
	   					Grid(i,11)=b(j+1)
	   				case "High52"
	   					Grid(i,12)=b(j+1)
	   				case "Low52"
	   					Grid(i,13)=b(j+1)
	   				
	 
	   			End Select 
	   		
  	Next 
  	
   
 
  
next 
 
 ReturnReult=""
	for i = 1 to UBound(a) 
	
			For j = 0 to 13 
				ReturnReult=ReturnReult &  Grid(i,j) & "|"
			next 
				
				ReturnReult=ReturnReult  & "*"
		
	Next 
 
 
 
 
  	 
  	
	 
 
 
Response.Write(ReturnReult)
 
%>

Open in new window

0
Comment
Question by:afnaz
  • 3
6 Comments
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 20327073
You cannot do xmlHttp to another server
You need a proxy - a server process on YOUR server that takes the url and returns the content from the other server
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 20327086
The reason it worked on your pc is the security is lower when you load a page from harrdisc

If you really need to, save your page with extension .HTA - it will prompt to open or save, but will work as if it came from harddisk
0
 

Author Comment

by:afnaz
ID: 20328409
thank u for the response.
I thing this is the security problem with my pc  then what is the other solution  for this type project.
i want to refresh the data with out refreshing pate in certane period with using javascript.
0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 125 total points
ID: 20328459
I already explained

1) You need to load the page from internet: create a server process that can grab the page on the server and send it to the browser as if it came from the same server - http://dotnetslackers.com/columns/ajax/MashitUpwithASPNETAJAX.aspx
2) You can just load something from the harddisc - use an HTA: http://msdn2.microsoft.com/EN-US/library/ms536496.aspx
0
 
LVL 1

Expert Comment

by:Computer101
ID: 20943716
Forced accept.

Computer101
Community Support Moderator
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question