almightyegg Posted July 26, 2007 Share Posted July 26, 2007 I have a script that I went through in a tutorial except it left a few bits out... 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(act) { // Open PHP script for requests http.abort; http.open('post', 'delete.php'); http.setRequestHeader('Content-Type', 'application/x-www-form- urlencoded'); http.send('act='+act); } if(http.readyState == 4 && http.status == 200){ // Text returned FROM the PHP script var response = http.responseText; if(response) { // UPDATE ajaxTest content document.getElementById("ajaxTest").innerHTML = response; } } } <input type="button" value="Send AJAX Request" id="sendButton" onClick="sendRequest('test1');" /> Basically, I'm a newbie to AJAX and JS so there are probably lots of errors here... the script I want to execute (delete.php) is this: <? include 'db.php'; // Connect to DB $email = $_COOKIE['email']; $password = $_COOKIE['password']; $sql = mysql_query("SELECT * FROM users WHERE email='$email' AND password='$password' AND activated='1'"); $mem = mysql_fetch_array($sql); $id = $_GET['t']; $f = $_GET['f']; $deletepost = mysql_query("DELETE FROM topics WHERE id = '$id' and fid = '$f' LIMIT 1"); $delpos = mysql_query($deletepost); ?> As you can see this requires two PHP variables...$t and $f, that go into a URL like so: delete.php?t=$t&f=$f what I need help with is getting this information into the AJAX script (I think it's the sendRequest() part) anyway thanks in advance Link to comment https://forums.phpfreaks.com/topic/61912-making-this-script-work/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.