Hi everyone: I just started to learn jquery and met this problem: I would like to use .ajax to send a http request. For example: I got the code like the following $.ajax( { type:"GET", url:"./include/coor_generator.php", complete:function (xhr,statusText) { alert(xhr.status); } } );
However, in 'coor_generator.php', I would like to verify if that user session is already verified or not, so that the content of 'coor_generator.php' is like: <?php require_once("session.php"); require_once("DB.php"); //DB class declartion $status_code = 1; header("Content-type: text/xml"); header("Cache-Control: no-cache"); echo "<?xml version=\"1.0\"?>\n"; echo "<response>\n"; echo "\t<status>$status_code</status>\n"; ...... ?> in 'session.php', the content is: <?php session_start(); setcookie(session_name(), session_id(), time() + 1*60, "/"); if(!(isset($_SESSION["username"]))||!(isset($_SESSION ["password"]))) { header("Refresh:0;url=./login.php"); exit(0); } ?> However, as I tested the script in Firebug, the returned xhr.status (in .ajax complete option) is always 200. Isn't it supposed to be 301 for redirection? My objective is very simple: if the user is verified, coor_generator.php generate some x,y coordinates in a valid XML format; however, if the user is not verified, redirect the user to the login page. How to achieve this using Jquery AJAX? Thanks a lot!!!