Dear all,

here is my AJAX file

<script language="javascript" type="text/javascript">
var xmlHttp;
var temp;

function showHint(str,IdDet,str2)
{
temp = IdDet;
if (str.length==0)
  {
  document.getElementById("txtHint"+temp).innerHTML="&euro;0";
  return;
  }
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }   
var url= "<?php echo $mosConfig_live_site."/administrator/components/com_virtuemart/html/basketAJAX.php";?>";
if(window.location.protocol == 'https:') url= str_replace("http://", "https://", url);
var params = "str1"=+str+"&str2"=+str2+"&IdDet="+IdDet;
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("POST",url,true);
xmlHttp.send(params);
} 

function stateChanged() 
{
	var total=0;
	var temp2="";
	
if (xmlHttp.readyState==4)
{
document.getElementById("txtHint"+temp).innerHTML=xmlHttp.responseText;
for(i=0;i< <?php echo $cart["idx"]?> ;i++)
{
	temp2=document.getElementById("txtHint"+i).innerHTML.split(String.fromCharCode(8364));
	value_temp=converter_value(temp2[1]);
	total=total+parseFloat(value_temp);
}

      switch ("<?php echo $iso_client_lang?>")
      {
         case "france":
            total = "&euro;"+number_format(total, 2, ',', ' ');
            break;
         case "deutsch":
            total = "&euro;"+number_format(total, 2, ',', '.');
            break;
         case "english":
         default:
            //english notation
            total = "&euro;"+number_format(total, 2, '.', ',');
      }

document.getElementById("txtHinttot").innerHTML= total;
}
}


function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

function converter_value(value)
{
   	          var noJunkpf = "";
   	          var withDollarpf = "";
   	          var foundDecimalpf = 0;
   	          var foundAlphaCharpf = 0;
  	          value += "";
   	          if (value == "") 
   	          { 
   	          	noJunkpf =0;
   	          }
  	          else
   	          {
	   	       for (j=0; j<=value.length; j++)
   	           {
   	            var thisChar = value.substring(j, j+1);
	   	        if ("<?php echo $iso_client_lang?>" != "english")
   		        {
   	             if(thisChar == ",")
   	             {   	           
   	             foundDecimalpf = 1;
   	             noJunkpf = noJunkpf + ".";
   	             }
   		        }
   		        else
   		        {
    	         if(thisChar == ".")
   	             {
   	              foundDecimalpf = 1;
   	              noJunkpf = noJunkpf + thisChar;
   	             }	
   		        }
   	            if((thisChar < "0") || (thisChar > "9"))
   	            {
   	             if((thisChar != ".") && (thisChar != ",") && (thisChar != " ") && (thisChar !="")) foundAlphaCharpf = 1;
   	            }
   	            else
   	            {
   	             withDollarpf = withDollarpf + thisChar;
   	             noJunkpf = noJunkpf + thisChar;
   	            }
   	            if((thisChar == ".") || (thisChar == ","))
   	            {
   	             withDollarpf = withDollarpf + thisChar;
   	            }
   	           }
   	          } 
   	          return noJunkpf;	
}


function number_format( number, decimals, dec_point, thousands_sep ) 
{
// * example 1: number_format(1234.5678, 2, '.', '');
// * returns 1: 1234.57
      var n = number, c = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals;
      var d = dec_point == undefined ? "," : dec_point;
      var t = thousands_sep == undefined ? "." : thousands_sep, s = n < 0 ? "-" : "";
      var i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
      return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
}

function str_replace(search, replace, subject) { 
    var s = subject;
    var ra = r instanceof Array, sa = s instanceof Array;
    var f = [].concat(search);
    var r = [].concat(replace);
    var i = (s = [].concat(s)).length;
    var j = 0;
    
    while (j = 0, i--) {
        if (s[i]) {
            while (s[i] = (s[i]+'').split(f[j]).join(ra ? r[j] || "" : r[0]), ++j in f){};
        }
    }
 
    return sa ? s : s[0];
}
</script>

and basketAJAX.php file
<?php
//get the q parameter from URL
$q1=$_GET["q1"];
$q2=$_GET["q2"];
$q3=$_GET["q3"];//id

 $sum=$q1*$q2;
require_once('../../../../joomframe.php');
$cart = $_SESSION['cart'];
$_SESSION['cart'][$q3]["quantity"]=$q1;

global $iso_client_lang;

      switch ($iso_client_lang)
      {
         case "france":
            echo "&euro;".number_format($sum, 2, ',', ' ');
            break;
         case "deutsch":
            echo "&euro;".number_format($sum, 2, ',', '.');
            break;
         case "english":
         default:
            //english notation
            echo "&euro;".number_format($sum, 2, '.', ',');
      }
?>

it runs well if we execute in http prototype, when we execute it in https, it seems that the value seems not to be pass to BasketAjax.php(it appears to be 0). Is there any problem in my AJAX file?How to pass the value that I get to basketAJAX.php.

thx a lot

it works with https
must be something else.
is the secure page doing anything different?
asking for login? etc...

This article has been dead for over six months. Start a new discussion instead.