Hi ,
In a form I have two funtions using that two ajax functions I retrieve values from mysql database.
My problem is both functions are not working at the same time, only neither one nor working.

Here I inserted the sample code, tell me the solution

<?php
include('./include/Connection.php');
?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<?php include("include/title.php");  ?>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!-- Le styles -->

<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700,800' rel='stylesheet' type='text/css'>
<!-- Le fav and touch icons -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="img/apple-touch-icon-144-precomposed.html">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="img/apple-touch-icon-114-precomposed.html">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="img/apple-touch-icon-72-precomposed.html">
<link rel="apple-touch-icon-precomposed" href="img/apple-touch-icon-57-precomposed.html">
<link rel="shortcut icon" href="img/favicon.png">
</head>
<body>
<?php include("include/header.php");  ?>
<?php include("include/menu.php");  ?>

<h5>Hi</h5>
<form name="frm_content" id="frm_content" method="post" enctype="multipart/form-data"/>


<div class="form_row">
<label class="field_name align_right">Client Name </label>
<div class="field"><input type="text" name="txt_cname" id="txt_cname" class="span8"/></div>
</div>

<div class="form_row">
<label class="field_name align_right">Client Type</label>
<div class="field"><input type="text" name="txt_ctype" id="txt_ctype" class="span8"   placeholder="Client Type" readonly/></div>
</div>

<div class="form_row">
<label class="field_name align_right">Address</label>
<div class="field"><input type="text" name="txt_cadd" id="txt_cadd" class="span8" placeholder="Client Address" readonly/></div>
</div>

<div class="form_row">
<label class="field_name align_right">Landline No</label>
<div class="field"><input type="text" name="txt_landline" id="txt_landline" class="span8"   placeholder="Landline No" readonly/></div>
</div>

<div class="form_row">
<label class="field_name align_right">Con.Name</label>
<div class="field"><input type="text" name="txt_name" id="txt_name" class="span8"  placeholder="Contact Person Name" readonly/></div>
</div>

<div class="form_row">
<label class="field_name align_right">Con.Mobile</label>
<div class="field"><input type="text" name="txt_mobile" id="txt_mobile" class="span8"    onKeyPress="return numbersonly(event);" placeholder="Contact Person Mobile" maxlength="10" readonly/></div>
</div>

<div class="form_row">
<label class="field_name align_right">Con.Email</label>
<div class="field"><input type="email" name="txt_email" id="txt_email" class="span8" placeholder="Contact Person Email"readonly/></div>
</div>

<div class="form_row">
<label class="field_name align_right">MD.Name</label>
<div class="field"><input type="text" name="txt_mname" id="txt_mname" class="span8"placeholder="MD Name" readonly/></div>
</div>

<div class="form_row">
<label class="field_name align_right">MD.Mobile</label>
<div class="field"><input type="text" name="txt_mmobile" id="txt_mmobile" class="span8"   onKeyPress="return numbersonly(event);" placeholder="MD Mobile" maxlength="10" readonly/></div>
</div>

<div class="form_row">
<label class="field_name align_right">MD.Email</label>
<div class="field"><input type="email" name="txt_memail" id="txt_memail" class="span8"placeholder="MD Email" readonly/></div>
</div>

<div class="form_row">
<label class="field_name align_right">Acc.Name</label>
<div class="field"><input type="text" name="txt_aname" id="txt_aname" class="span8"  placeholder="Accountant Name" readonly/></div>
</div>

</td>
<td width="50%">

<div class="form_row">
<label class="field_name align_right">Acc.Mobile</label>
<div class="field"><input type="text" name="txt_amobile" id="txt_amobile" class="span8" onKeyPress="return numbersonly(event);" placeholder="Accountant Mobile" maxlength="10" readonly/></div>
</div>

<div class="form_row">
<label class="field_name align_right">Acc.Email</label>
<div class="field"><input type="email" name="txt_aemail" id="txt_aemail" class="span8" placeholder="Accountant Email" readonly/></div>
</div>

<input name="txt_sid" id="txt_sid"  type="hidden" />
<div class="form_row">
<label class="field_name align_right">Service Name</label>
<div class="field"><input type="text" name="txt_service" id="txt_service" class="span8" onClick="empty1();"  onBlur="anna(this.value);"   placeholder="Service Name" /></div>
</div>
<div class="form_row">
<label class="field_name align_right">Sub Name</label>
<div class="field"><input type="text" name="txt_sub" id="txt_sub" class="span8"  placeholder="Sub Service Name"/></div>
</div>

<input class="btn blue" type="submit" name="Submit" id="Submit" value="Submit"/>
</form>



<script type="text/javascript">
<!--------------------------Ajax Start--------------------------------->
var xmlhttp
function liveGod(thala)
{
alert("fghsdkfk");
if (thala.length==0)
  {
  document.getElementById("mjanto").innerHTML="";
  return;
  }
 xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Your browser does not support XMLHTTP!");
  return;
  }
var url="getsuccess.php";
url=url+"?q="+thala;
url=url+"&sid="+Math.random();
alert(url);
xmlhttp.onreadystatechange=stateChanged_unameck;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
function stateChanged_unameck()
{
//alert(xmlhttp.responseText);
if (xmlhttp.readyState==4)
  {

//  document.getElementById("cp").innerHTML='';
  if(xmlhttp.responseText=="0")
  {
 // document.getElementById("cp").innerHTML=xmlhttp.responseText;
  }
  else
  {
  var rrr=xmlhttp.responseText;
  var rrr1 = rrr.split(","); 
  alert (rrr1);
  document.getElementById("txt_id").value=rrr1[0];
  document.getElementById("txt_ctype").value=rrr1[1];
  document.getElementById("txt_cadd").value=rrr1[2];
  document.getElementById("txt_landline").value=rrr1[3];
  document.getElementById("txt_name").value=rrr1[4];
  document.getElementById("txt_mobile").value=rrr1[5];
  document.getElementById("txt_email").value=rrr1[6];
  document.getElementById("txt_mname").value=rrr1[7];
  document.getElementById("txt_mmobile").value=rrr1[8];
  document.getElementById("txt_memail").value=rrr1[9];
  document.getElementById("txt_aname").value=rrr1[10];
  document.getElementById("txt_amobile").value=rrr1[11];
  document.getElementById("txt_aemail").value=rrr1[12];
  }
  }
}
function empty()
{

  document.getElementById("txt_id").value="";
  document.getElementById("txt_ctype").value="";
  document.getElementById("txt_cadd").value="";
  document.getElementById("txt_landline").value="";
  document.getElementById("txt_name").value="";
  document.getElementById("txt_mobile").value="";
  document.getElementById("txt_email").value="";
  document.getElementById("txt_mname").value="";
  document.getElementById("txt_mmobile").value="";
  document.getElementById("txt_memail").value="";
  document.getElementById("txt_aname").value="";
  document.getElementById("txt_amobile").value="";
  document.getElementById("txt_aemail").value="";

}
function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}
<!-------------------------------Ajax End------------------------------------->
<!-------------------------------Service Ajax Start----------------------------->
var xmlhttp1;
function anna(elbr)
{
alert("vchbfgn");
if (elbr.length==0)
  {
  document.getElementById("mercy").innerHTML="";
  return;
  }
  xmlhttp1=GetXmlHttpObject();
if (xmlhttp1==null)
  {
  alert ("Your browser does not support XMLHTTP!");
  return;
  }
var url1="getservice.php";
url1=url1+"?jaj="+elbr;
url1=url1+"&bid="+Math.random();
alert(url1);
xmlhttp1.onreadystatechange=stateChanged_unameck;
xmlhttp1.open("GET",url1,true);
xmlhttp1.send(null);
}
function stateChanged_unameck()
{
//alert(xmlhttp.responseText);
if (xmlhttp1.readyState==4)
  {

//  document.getElementById("cp").innerHTML='';
  if(xmlhttp1.responseText=="0")
  {
 // document.getElementById("cp").innerHTML=xmlhttp.responseText;
  }
  else
  {
  var sss=xmlhttp1.responseText;
  var sss1 = sss.split(","); 
  alert (sss1);
  document.getElementById("txt_sid").value=sss1[0];
  document.getElementById("txt_service").value=sss1[1];
  document.getElementById("txt_sub").value=sss1[2];
  }
  }
}
function empty1()
{
  document.getElementById("txt_sid").value="";
  document.getElementById("txt_service").value="";
  document.getElementById("txt_sub").value="";
}
function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}
<!-------------------------------Service Ajax End------------------------------------->

</script>

</body>
</html>

Get Service.php:

<?php
include('./include/Connection.php');
$key=$_REQUEST['jaj'];
$sql=mysql_query("select * from tbl_invoice_service where servicename='$key'") or die (mysql_error());
$hate=mysql_num_rows($sql);

if($hate>0)
{
    $row_a=mysql_fetch_array($sql);
    $b='';
    $b.=$row_a['sid'].',';
    $b.=$row_a['servicename'].',';
    $b.=$row_a['subname'];
    echo $b;

}
else
{
echo '0';
}
?>

Getsuccess.php

<?php
include('./include/Connection.php');
$key=$_REQUEST['q'];
$sql=mysql_query("select * from tbl_invoice_client where client_name='$key'") or die (mysql_error());
$love=mysql_num_rows($sql);

if($love>0)
{
    $row_a=mysql_fetch_array($sql);
    $a='';
    $a.=$row_a['id'].',';
    $a.=$row_a['client_type'].',';
    $a.=$row_a['client_add'].',';
    $a.=$row_a['landline'].',';
    $a.=$row_a['con_name'].',';
    $a.=$row_a['con_mobile'].',';
    $a.=$row_a['con_email'].',';
    $a.=$row_a['md_name'].',';
    $a.=$row_a['md_mobile'].',';
    $a.=$row_a['md_email'].',';
    $a.=$row_a['acc_name'].',';
    $a.=$row_a['acc_mobile'].',';
    $a.=$row_a['acc_email'];
    echo $a;

}
else
{
echo '0';
}
?>

-------------------------------------------------
I am in emergency , I need your help.

Change the ajax function names, because both ajax functions use the same name for example function GetXmlHttpObject(); in both functions.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.