$ _SESSION ['id']似乎不起作用

I have php page that has jquery ajax call. the begging of this page for sure sets $_SESSION['id'] properly, here is the code:

<?php
    session_start();
    if(!isset($_SESSION['id'])){
            header('Location: ../index.php');
    }
    else{
            $id = $_SESSION['id'];
    }
...?>

the ajax call code:

   $.ajax({
         url: '../php/functions/user_unused_area_list.php',
         dataType: 'json'        
    }).always(userUnusedAreaList);

  function userUnusedAreaList(list, textStatus, error){
    if(textStatus === 'success'){
        alert(list);
    }
    else {
       alert('Failed: ' + error);
    }
}

and here is the pho page which the ajax request calls:

if(isset($_SESSION['id'])){
    $id = $_SESSION['id'];
    echo 'good';
}
else{
    echo 'not good';
}

I'm getting an alert with Feiled: SyntaxError: UnexpectedToken n. (I think it from "not good") NOTE: there are other ajax calls and they look the same and they work fine, this one wasted many hours of my life.

thanks!

查看全部
weixin_33712987
weixin_33712987
2012/10/03 23:50
  • session
  • php
  • ajax
  • javascript
  • jquery
  • 点赞
  • 收藏
  • 回答
    私信

1个回复