I am using AJAX to insert, update and delete to and from a database.
My problem is it doesn't always work sometimes it does and sometimes it doesn't.
When I just post the form data my database is always updated so there no problem at that end.
Here is my AJAX, can anyone help me?
My problem is it doesn't always work sometimes it does and sometimes it doesn't.
When I just post the form data my database is always updated so there no problem at that end.
Here is my AJAX, can anyone help me?
Code:
function add_company_function()
{
var strCompanyCode = document.getElementById("CompanyCode").value;
var strCompanyDescription = document.getElementById("CompanyDescription").value;
var strModule = document.getElementById("Module").value;
var strLogoID = document.getElementById("LogoID").value;
var strParams = "CompanyCode=" + strCompanyCode;
strParams += "&CompanyDescription=" + strCompanyDescription;
strParams += "&Module=" + strModule;
strParams += "&LogoID=" + strLogoID;
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("divResult").innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open("POST","add_company.asp",true);
xmlhttp.setRequestHeader("Content-type", "application/x-[URL unfurl="true"]www-form-urlencoded");[/URL]
xmlhttp.setRequestHeader("Content-length", strParams.length);
xmlhttp.setRequestHeader("Connection", "close");
xmlhttp.send(strParams);
}