Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ajax get request is sending data but its not being received

    I have a form, which executes a javascript function when you click the submit button
    The function, then assembles a get request string to send to a php script. The code for this is :
    Code:
    var sendStr;
    	sendStr = "comments.php?item="+document.getElementById("iItemName").value;
    	sendStr += "&desc="+document.getElementById("iItemDesc").value;
    	sendStr += "&found="+document.getElementById("iFoundAt").value;
    	sendStr += "&auther="+document.getElementById("iPostedBy").value;
    	alert(sendStr);
        xmlHttp.open("GET",sendStr,true);
        xmlHttp.send(null);
    The php scrip then assembles the get requests into an array as follows :
    Code:
    if (isset($_GET['item'])) {
    		$itemName = $_GET['item'];
    		if (isset($itemDesc)) {
    			$itemDesc = $_GET['desc'];
    			if (isset($_GET['found'])) {
    				$foundAt = $_GET['found'];
    				if (isset($_GET['auther'])) {
    					$postedBy = $_GET['auther'];
    				} else {
    					die("error");
    				}
    			} else {
    				die("error");
    			}
    		} else {
    			die("error");
    		}
    	} else {
    		die("error");
    	}
    however the script just always dies with error.
    i thought that the javascript wasent assembling the string correctly, however, i added an alert for the string before submitting it, and it seems compleatly fine.
    can anyone shed any light?
    regards
    Bodyloss

  • #2
    New to the CF scene
    Join Date
    Jul 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hey
    dont worry
    i fixed it
    all i had to do was to replace that confusing and long multiple if statment, with just the one and lots of &&'s


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •