PDA

View Full Version : new to ajax. this attempt to post is not working.



antonyf
12-08-2011, 08:49 PM
Hi i have a ajax function but its not working. I am new to ajax. I cannot use a Jquery or Prototype or mootools equivalent of this code they all conflict with my website.

here is my code:


me.emailCheckout = function() {
var div = me.updateCartView( document.createElement("diver") );
diver = "<div class='StoreCart_items'>" + div.innerHTML + "</div>";
var buyersalute = getElementById("buyersalute");
var buyerfirstname = getElementById("buyerfirstname");
var buyerlastname = getElementById("buyerlastname");
var buyerstreet = getElementById("buyerstreet");
var buyertown = getElementById("buyertown");
var buyerregion = getElementById("buyerregion");
var buyercountry = getElementById("buyercountry");
var buyerpostalcode = getElementById("buyerpostalcode");
var buyercontact = getElementById("buyercontact");
var buyermobile = getElementById("buyermobile");
var buyeremail = getElementById("buyeremail");
var buyerprefpay = getElementById("buyerprefpay");
var buyerspecreq = getElementById("buyerspecreq");
var adminemail = getElementById("adminemail");
var adminstorename = getElementById("adminstorename");

var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("theResponce").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("POST","email.php",true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send("div=diver&buyersalute=buyersalute&buyerfirstname=buyerfirstname&buyerlastname=buyerlastname&buyerstreet=buyerstreet&buyertown=buyertown&buyerregion=buyerregion&buyercountry=buyercountry&buyerpostalcode=buyerpostalcode&buyercontact=buyercontact&buyermobile=buyermobile&buyeremail=buyeremail&buyerprefpay=buyerprefpay&buyerspecreq=buyerspecreq&adminemail=adminemail&adminstorename=adminstorename");
};