Jump to content

AJAX Loop Help Needed


savagenoob

Recommended Posts

I have a main page that i want to send AJAX requests to see if client has accepted agreements, then dynamically load check marks next to the disclosures as they accept them. Here is the main page:

<form name='emailclient'>
Email: <input type='text' value = '<?php echo $email;  ?>' name='email' id = 'email' /> <br />
<input type="hidden" value="<?php echo $clientid; ?>" id = "transid" name="transid" />
<input type="hidden" value="<?php echo $agent; ?>" id = "agentname" name="agentname" />
<input type="hidden" value="<?php echo $agency; ?>" id = "agency" name="agency" />
<input type='button' onclick='emailFunction()' value='Email Client' />
</form>
<div id='ajaxDiv'>Message will display when email is successful.</div><br />
<input type="hidden" value="<?php echo $finid; ?>" id = "transid" name="transid" />
Agreement to Apply For and/or Purchase Automobile Insurance Electronically
<div id = "disclosure1"></div><br />
Certification of Snap Online Policy Engine Application Information, Content, and Coverages
<div id = "disclosure2"></div><br />
Declarations
<div id = "disclosure3"></div>

My ajax :

var getv=-1;
var page="getupdate.php";

function getData(){

while(getv!=-1){}
if (window.XMLHttpRequest) {
getv= new XMLHttpRequest();
if (getv.overrideMimeType){
getv.overrideMimeType("text/xml");
}
}else if (window.ActiveXObject) {
try {
getv = new ActiveXObject("Msxml2.xmlHttp");
getv.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
}catch (e) {
try {
getv= new ActiveXObject("Microsoft.xmlHttp");
}catch (e) {}
}
}
ret=-1;
getv.onreadystatechange = function(){
if (getv.readyState == 4) {
ret=getv.responseText;
update(ret);
getv=-1;
}
};
var transid = document.getElementById('transid').value;
var queryString = "?transid=" + transid;
getv.open("GET", page + queryString);
try{
getv.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
}
catch(e){}
getv.send("");
return ret;

return 0;
settimeout("getData()",500);
}
function update(value){
var data=value.split(";");
document.getElementById("disclosure1").innerHTML=data[0];
document.getElementById("disclosure2").innerHTML=data[1];
document.getElementById("disclosure3").innerHTML=data[2];
}
window.onload = getData;

Then my PHP page:

<?php

$transid = $_GET['transid'];

$disclose = mysql_query("SELECT * FROM disclosures WHERE transid = '$transid'") or die(mysql_error());
while($disc = mysql_fetch_array($disclose)){
    echo $disc['disclosure'];
    
    if($disc['complete'] = "accept"){
?>
<img src="../images/folder.png" width="20" height="20" align="absmiddle" />
<?php        
    }
    
}
?>

Its not working, maybe someon can help.

Link to comment
https://forums.phpfreaks.com/topic/216330-ajax-loop-help-needed/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.