In your PHP script, you're suppose to print (echo) your response. Make
sure to put an 'exit' afterwards so you don't continue processing the
rest of your script and return (print) unexpected content.

On Mar 8, 11:17 am, Ethan <[email protected]> wrote:
> Hi out there.  I'm having a little trouble with my .ajax.  Here's the
> function:
>
> var name = $('#username').val();
> var pass = $('#pass').val();
>
> $.ajax({
>                 url: 'signin.php',
>                 type: 'GET',
>                 data: 'username=' + name + '&pass=' + pass,
>                 success: function(submitreturn){
>                         alert(submitreturn);
>                 }
>         });
>
> Here's signin.php:
>
> <?php
>
> require_once("classes/Login.php");
>
> $user = $_GET['username'];
> $pass = $_GET['pass'];
>
> $login = new Login();
>
> if($login->login_user($user, md5(md5($pass) . POSTPASSKEY)))
> {
>                 return "I DID IT";}
>
> else
> {
>                 return "I DIDNT DO IT";
>
> }
>
> ?>
>
> Okay, so here's my question.  When the .ajax runs, the alert window
> contains the string that was in the username input, and <br />.  Why
> is this?  Why isn't submitreturn the value that was returned by
> signin.php?  How can I get the value returned by signin.php?
>
> Thanks for your help!
>
> -Ethan

Reply via email to