Error javascrip
Hi All
Here is my file javascrip
--------------------------
var oPopup = window.createPopup();
function ConratulationAdd()
{
var oPopBody = oPopup.document.body;
oPopBody.style.backgroundColor = "lightyellow";
oPopBody.style.border = "solid black 1px";
oPopBody.innerHTML = "Thanks you ! Your Cart have been add To Cart.";
oPopup.show(event.clientX-50, event.clientY-60, 200, 50, document.body);
}
function hamxuly(objAjaxTest)
{
//alert(objAjaxTest.DOMDocument)
var rootNode = objAjaxTest.SelectSingleNode('Products');
var products = rootNode.childNodes;
var str ="<table border='0'>";
str=str + "<tr><td width='200'> DESIGNATION</td><td width='30'> QTE</td><td width='30'>TOTAL</td></tr>"
var mQuanlity=0;
var mTotal=0;
for ( var j = 0 ; j < products.length ; j++ )
{
str=str + "<tr>"
var product = products[j] ;
var ProductID = (product.attributes.getNamedItem('ProductID')!=nul l)?product.attributes.getNamedItem('ProductID').va lue:"" ;
var ProductName = (product.attributes.getNamedItem('ProductName')!=n ull)?product.attributes.getNamedItem('ProductName' ).value:"" ;
var Quanlity = (product.attributes.getNamedItem('Quanlity')!=null )?product.attributes.getNamedItem('Quanlity').valu e:"" ;
var Total = (product.attributes.getNamedItem('Total')!=null)?p roduct.attributes.getNamedItem('Total').value:"" ;
mQuanlity= mQuanlity + Number(Quanlity);
mTotal=mTotal + Number(Total);
str=str + "<td width='200'>" + "" + ProductName + "" + "</td>"
str=str + "<td width='30' align='center'>" + "" + Quanlity + "" + "</td>"
str=str + "<td width='30' align='center'>" + "" + Total + "" + "</td>"
str=str + "</tr>"
}
str=str + "<tr><td align='right'>" + ""+" Total" + "</td><td width='30' align='center'>" + "" + mQuanlity + "" + "</td><td width='30'align='center'>" + "" + mTotal + "" + "</td></tr>"
str= str + "</table>"
document.getElementById("myBag").innerHTML=str
}
//--------------------
var AjaxTest = function()
{
}
AjaxTest.prototype.GetHttpRequest = function()
{
//alert("Thanks you ! To continue please press ok"); dua cai alert nao vao thi ok
ConratulationAdd();
if ( window.XMLHttpRequest )
{ // Gecko
return new XMLHttpRequest() ;
}
else if ( window.ActiveXObject ) // IE
{
try{
return new ActiveXObject("MsXml2.XmlHttp") ;
}
catch(e)
{
return new ActiveXObject("Microsoft.XMLHTTP") ;
}
}
}
//---------------------
AjaxTest.prototype.GoiAjaxTest_Text = function(urlToCall,hamXuLyKetqua)
{
var objAjaxTest = this ;
var bAsync = ( typeof(hamXuLyKetqua) == 'function' ) ;
var oXmlHttp = this.GetHttpRequest();
oXmlHttp.open( "GET", urlToCall, bAsync ) ;
if ( bAsync )
{
oXmlHttp.onreadystatechange = function()
{
if ( oXmlHttp.readyState == 4 )
{
objAjaxTest.DOMDocument = oXmlHttp.responseXML;
if ( oXmlHttp.status == 200 || oXmlHttp.status == 304 )
{
hamXuLyKetqua(objAjaxTest) ;
}
else
alert( 'XML request error: ' + oXmlHttp.statusText + ' (' + oXmlHttp.status + ')' ) ;
}
}
}
oXmlHttp.send(null) ;
//alert(
}
AjaxTest.prototype.SelectSingleNode = function( xpath )
{
if ( document.all )
{
// IE
return this.DOMDocument.selectSingleNode( xpath );
}
else // Gecko
{
var xPathResult = this.DOMDocument.evaluate( xpath, this.DOMDocument,
this.DOMDocument.createNSResolver(this.DOMDocument .documentElement), 9, null);
if ( xPathResult && xPathResult.singleNodeValue )
return xPathResult.singleNodeValue ;
else
return null ;
}
oPopup.hide();
}
-------------------------------
Here is my javascrip at my code :
function ajax_do(url) {
url="<%= Page.ResolveUrl("~/DesktopModules/Asieco_ProductsView/AddData.aspx") %>"+url;
/*
var jsel = document.createElement('script');
jsel.type = "text/javascript";
jsel.src = url;
*/
var ajaxtest=new AjaxTest();
ajaxtest.GoiAjaxTest_Text(url,hamxuly);
}
function doAdd(ProductID)
{
var sGetText;
sGetText="txt" + ProductID;
var intQuanlity=document.getElementById("txt"+ProductI D).value;
if (isNaN(intQuanlity))
{
alert("You have to input number");
return;
}
ajax_do("?id="+ProductID+"&txt"+ProductID+"="+intQ uanlity);
}
when function "doadd" run. at my site( asieco.net) then it's Error : XML request error.
But this site can run at my local machine well
Please help me fix this error
Thanks
phuong
|