Re: php and Ajax problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Richard Kurth wrote:
I can not figure out way this is not working can somebody help?
<html>
<head>
 <title>Untitled</title>
<script language="JavaScript">
function createRequestObject() {
var req; if(window.XMLHttpRequest){
      // Firefox, Safari, Opera...
      req = new XMLHttpRequest();
   } else if(window.ActiveXObject) {
      // Internet Explorer 5+
      req = new ActiveXObject("Microsoft.XMLHTTP");
   } else {
      // There is an error creating the object,
      // just as an old browser is being used.
      alert('Problem creating the XMLHttpRequest object');
   }
return req; } // Make the XMLHttpRequest object
var http = createRequestObject();
function sendRequest(action,arg) {
   // Open PHP script for requests
   http.open('get', 'eventaction.php?takeaction='+action+'&uid='+arg);
   http.onreadystatechange = handleResponse;
   http.send(null);
} function handleResponse() {
    if(http.readyState == 4){
        var response = http.responseText;
        var update = new Array();
if(response.indexOf('|' != -1)) {

So, if it doesn't find a | (pipe) in the returned page, it won't do anything!

            update = response.split('|');
            document.getElementById(update[0]).innerHTML = update[1];
        }
    }
}
</script>
</head>
<body> <?php $event['deleteevent']='<a
href="javascript:sendRequest(delete,32423434234234234324)">Delete this
event</a>';
echo $event['deleteevent'];
?>
</body>
</html>
this is the 'eventaction.php script yo test if the ajax script works
<?

Does your server allow for short_tags = On ???
if($_GET['takeaction']=="delete"){
$uid=$_GET['uid'];
echo $uid;

Well, as mentioned above, where is the | (pipe) that your JS code is expecting???

Plus, where is the name of the object that you are wanting to take action upon? Looks like your JS is needing something like this.

echo "{$div_id}|{$uid}";

Hope this helps

exit;
}
?>


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux