Re: php and Ajax problem
| From: | Tijnema | Date: | Mon, 28 May 2007 19:44:49 +0000 |
| Subject: | Re: php and Ajax problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-255719@lists.php.net to get a copy of this message | ||
On 5/28/07, Richard Kurth <richardkurth@centurytel.net> 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){Try firefox and take a look at the javascript console, it points you to any javascript syntax errors. Tijnema// 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)) { 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 <? if($_GET['takeaction']=="delete"){ $uid=$_GET['uid']; echo $uid; exit; } ?>