AJAX to PHP - PHP form data does not seem to post in AJAX function

Hello,

I am dealing with an AJAX issue in osCommerce, and I have received good advice on assorted subjects in this forum. I am new to this whole process, so please forgive my ignorance. That said a client of mine is trying to get me to AJAX the heck out of the PHP backend. While I am aware of tools such as ajax_shopping_cart v2.0, I really am trying to figure out how to do this myself so that I can apply AJAX to pretty much every possible form. I have been testing some AJAX on the product_info.php file so that when the user submits the form it returns the output which (for now) changes the innerHTML of the body to the response HTML. So basically, for example, I have adjusted the code so that the action is an AJAX call. The top of the form reads like this


<form name="cart_quantity" action="java script:cartresponse('[mydomainnamehere]/Store/product_info.php?products_id=21&action=add_product')" method="post" >

where [mydomainnamehere] represents the redacted domain name.

The AJAX code looks like this:


var xmlHttp

function cartresponse(cartadder)
{ 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
var url=cartadder
xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("POST",url,true)
xmlHttp.send(null)
}

function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
alert("Response PHP:
" +xmlHttp.responseText);
document.body.innerHTML=xmlHttp.responseText
 } 
}

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;
}

It’s generic AJAX I pulled from w3schools. What’s happening is that though it supposedly sends the data, when it gets the response (which it does) and changes the body HTML, the product is not added.

I hope that this is just a simple matter of my more explicitly passing data through the POST, or using GET instead of POST, but any (timely preferably) help would be greatly appreciated.

Thanks for your time