cant get ajax response (JSON) to call 'success' function?

Posted by Haroldo on Stack Overflow See other posts from Stack Overflow or by Haroldo
Published on 2010-05-17T17:54:34Z Indexed on 2010/05/17 18:00 UTC
Read the original article Hit count: 135

Filed under:
|
|

for some reason the success function isnt being called?

javscript:

$.ajax({  
            type: 'POST',
            url: 'http://localhost/hf_latest_desktop/st_pages/user_area/acc_buttons/pass_change/pass_change_ajax.php',
            data: data,
            dataType: 'json',
            success: function(e){ 
                console.log(e);
                if(e.status == 'success'){
                    alert('your password has been changed!');
                }   
                if(e.status == 'error1'){
                    alert('please fill in all inputs!');
                }
                if(e.status == 'error2'){
                    alert('password incorrect!');
                }
                if(e.status == 'error3'){
                    alert('change failed!');
                } 
            } 
        }); 

php file ajax is calling to:

    <?php session_start();
    session_cache_limiter('nocache');
    header('Expires: ' . gmdate('r', 0));
    header('Content-type: application/json');
    $status = 'error1'; //for sake of example
    ?>
    {'status':'<?php echo $status; ?>'} 

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about AJAX