garethhall Posted July 19, 2009 Share Posted July 19, 2009 Hello I have this php and ajax working together to update a DB. Now the code works if in safari firefox but doesn't seem to work IE Any ideas way? PHP <?php do {$i++; ?> <tr class="tableBG1" <? echo ($i % 2? 'bgcolor="#262626"' : 'bgcolor="#2E2E2E"'); ?> > <form name="formId<?php echo $row_rs_ListPages['pageId']; ?>" method="post" action=""> <td class="leftRow"> <span > <input name="pageId" type="hidden" id="pageId" value="<?php echo $row_rs_ListPages['pageId']; ?>" /> <?php echo $row_rs_ListPages['pageMetaTitle']; ?></span></td> <td class="leftRow"><?php echo $row_rs_ListPages['pageMetaDescription']; ?></td> <td class="leftRow"><?php echo $row_rs_ListPages['pageDate']; ?></td> <td class="leftRow" align="center" valign="middle"><a href="cmsEditPage.php?pageId=<?php echo $row_rs_ListPages['pageId']; ?>"><img src="cmsImages/btnEdit.png" width="56" height="16" alt="Edit" /></a> <a href="<?php echo $row_rs_ListPages['pagePath']; ?>" target="_blank"><img src="cmsImages/btnView.png" width="56" height="16" alt="Delete" /></a> <input <?php if ($row_rs_ListPages['pageStatus'] == "on") {echo "checked ='checked'";} ?> type="radio" name="status" onchange="updatePageStatus(pageId.value, status.value='on')" /> On <input <?php if ($row_rs_ListPages['pageStatus'] == "off") {echo "checked ='checked'";} ?> type="radio" name="status" onchange="updatePageStatus(pageId.value, status.value='off')" /> Off<br /> </td> <td class="rightRowDouble"><div id="<? echo $row_rs_ListPages['pageId'] ?>"> </div></td> </form> </tr> <?php } while ($row_rs_ListPages = mysql_fetch_assoc($rs_ListPages)); ?> And here is the Ajax var xmlHttp var id; function updatePageStatus(pageId, status){ xmlHttp=GetXmlHttpObject() if(xmlHttp==null){ alert("Browser does not support HTTP Request"); return; }; var url="cmsLiveUpdatePageStatus.php"; url += "?pageId="+pageId; url += "&pageStatus="+status; id = pageId; alert(url); xmlHttp.onreadystatechange=stateChanged ; xmlHttp.open("GET",url,true); xmlHttp.send(null); }; function stateChanged(){ if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ document.getElementById(id).innerHTML=xmlHttp.responseText; }; }; function GetXmlHttpObject(){ var xmlHttp=null; try{ // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); }catch (e){ // Internet Explorer try{ xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }catch (e){ xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }; }; return xmlHttp; }; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.