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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.