Let say I submit data to a form with the following code
var xhr = new XMLHttpRequest(), formData = new FormData(); formData.append("img", img); formData.append("user", localStorage["username"]); formData.append("pass", localStorage["password"]); xhr.onreadystatechange = function (event) { if (xhr.readyState === 4 && xhr.status === 200) { var value = xhr.responseText; // value should equal "1234" alert( "value = " + value ); }else{ alert("none"); } }; xhr.open("POST", "http://joubin.me/uploads3/upload_file.php", true); xhr.send(formData); After upload.php is done, it redirects to another page called giveid.php and the only thing it displays is a text string with an id
say 1234
How can I with javascript capture this exact id.
Keep in mind, a different upload.php redirect will have a different id number on giveid.php?
I looked into the xmlhtml responses and could not figure it out.
Here is what form goes
$password = $_REQUEST['pass']; $username = $_REQUEST['user']; $image = $_REQUEST['img']; echo $password; echo "<br/>"; echo $username; echo "<br/>"; echo $image; $con = mysql_connect("localhost","ya","right"); if (!$con) { die('Could not connect: ' . mysql_error()); echo "could not connect"; } $asql = "SELECT * FROM `ashkan`.`users` where user='$username' and pass='$password';"; $result = mysql_query($asql); echo $result; // Mysql_num_row is counting table row $count=mysql_num_rows($result); echo $count; echo 11; if($count == 1){ $sql = "INSERT INTO `ashkan`.`goog` (`user`, `pass`, `img`) VALUES ('$username', '$passwo$ } mysql_query($sql); mysql_close($con); header( 'Location: giveid.php' ) ; and here is the content of giveid.php
1234 Any help would be great.
Thanks
$.post(url,fn)