PDA

View Full Version : Firefox ajax



Independent
18-06-2008, 05:41 PM
<script type="text/javascript">
function addrep(){

alert('Sorry - but you cannot add reputation to <?php echo $propername; ?>!');
}
function send()
{
var url = 'send.php?from=<?php echo $nivusr; ?>&type=message';
if(window.XMLHttpRequest)
{
httpAjax = new XMLHttpRequest();
}
else if(window.ActiveXObject)
{
httpAjax = new ActiveXObject("Microsoft.XMLHTTP");
}
httpAjax.open("POST", url, true);
httpAjax.onreadystatechange = saved;
httpAjax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
httpAjax.send();
}

function addfriend()
{
var url = '../friend.php?from=<? echo $nivusr; ?>&add=<? echo $propername; ?>';
if(window.XMLHttpRequest)
{
httpAjax = new XMLHttpRequest();
}
else if(window.ActiveXObject)
{
httpAjax = new ActiveXObject("Microsoft.XMLHTTP");
}
httpAjax.open("POST", url, true);
httpAjax.onreadystatechange = saved;
httpAjax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
httpAjax.send();
}
function saved() {
alert("A friend request has been dispatched too <?php echo $propername; ?>\n\nYou have to wait for <?php echo $propername; ?> to accept the request!");
}
</script>


Sorry to hastle, but please could someone fix this code too work in Firefox, I'm not too sure why but this code only works in Internet explorer.

+REP to anybody who helps.

Dentafrice
18-06-2008, 05:48 PM
Why not use Prototype and then just use Ajax.Request, and it works crossbrowser.

Independent
18-06-2008, 05:49 PM
Why not use Prototype and then just use Ajax.Request, and it works crossbrowser.
I suck with javascript more than I do with PHP, but thanks will try see into it.

Want to hide these adverts? Register an account for free!