Problem with jQuery.ajax ()

Problem with jQuery.ajax ()

Good afternoon,

I'm having a problem with the method jQuery.ajax () and ja walked laps here and did not find solution anywhere.

What happens is this, you have this code in functions.js:

  1. function login()
  2. {
  3.     var user = jQuery("#user_login").val();
  4.     var pass = jQuery("#pass_login").val();

  5.     jQuery("section #login").effect("fade", 500);
  6.     jQuery.ajax({
  7.         type: "POST",
  8.         url: "ws/login.php",
  9.         dataType: "json",
  10.         data: {
  11.             user: user,
  12.             pass: pass
  13.         },
  14.         success: function (data)
  15.         {
  16.             alert("data " + data);
  17.         },
  18.         error: function (data)
  19.         {
  20.             alert("data " + data.toString());
  21.         }
  22.     });
  23. }

And in functions.php i have:
  1. <?PHP
  2. if(isset($_POST['user']) && isset($_POST['pass']))
  3. {
  4.     //Verificar na db se estas credenciais existem 
  5.     require_once '../include/connectDB.php';
  6.     $db = ligacaoDB();
  7.     $query = "SELECT NOME, SENHA, ID_UTILIZADOR, to_char(sysdate, 'yyyy/mm/dd hh24:mi:ss')
  8.         from ADM_UTILIZADORES where ID_UTILIZADOR='$_POST[user]'";    
  9.     $result = oci_parse($db, $query); 
  10.     oci_execute($result);
  11.     $sql = oci_fetch_array($result, OCI_NUM + OCI_RETURN_NULLS);
  12.     if($sql)
  13.     {
  14.         session_start();
  15.         $_SESSION['user'] = $_POST['user'];
  16.         $_SESSION['name'] = $sql[0];
  17.         $_SESSION['pass'] = $sql[1];
  18.         $_SESSION['user_id'] = $sql[2];
  19.         $_SESSION['session_start'] =$sql[3];        
  20.         echo json_response("Bem-Vindo" . $sql[0]);
  21.     }
  22. }
  23. ?>

  1. <?php
  2.     function json_response($message, $response = true) {
  3.         return json_encode(
  4.             array(
  5.                 'response' => $response,
  6.                 'message' => $message
  7.             )
  8.         );
  9.     }
  10. ?>
With that, he always give back to me the error, and not know why. Will can help me?