0
$('#SaveProfile').bind("click", function(){

        var pass_entered = $('#pass_entered').val();;
        var access = false;

        //check for the password entered if correct
        $.ajax({

            type:'GET',
            url:'../process/passProtectionCheck.php',
            dataType:'json',
            data:{password:'pass_entered'},

            success:function(e){

                access = $(e).val();

                if(access != true){
                    //if password is wrong notify user!!
                    alert('Password Entered is Incorrect Data cannot be Save');

                }else{
                    //if password is correct save data
                    alert('Password Entered Matchec!!');


                }
            }

        });

    });

Can anyone help me how accept return values from $_GET with jquery ajax
my php file return a boolean variable access ...

3
Contributors
4
Replies
5
Views
4 Years
Discussion Span
Last Post by radhakrishna.p
1

success:function(e){ e is the return value from the php file

for example passProtectionCheck.php where you gonna gor through the get process
echo "Success"; from passProtectionCheck.php as you echo "Succes" is the return value of an ajax request try to alert(e); onsuccess of an ajax request then there will be a popup alert "Success" from the page

Votes + Comments
well described
1

success:function(e){ start from this line e is the return value
then store to variable like var access = e;

0

make (or) store your boolean variable value into an php array as follows

$out_val = array("result"=>'your value here');
echo json_encode($out_val);

and read this value in your script code by using Json.parse() as follows

success:function(e){
                var actual = JSON.parse(e);
                alert(actual.result)

            }

check it once by making changes in your php file as well as in script code

check whether the alert box gives your desired result or not

let me know the status after updating with the code above

happy coding

Edited by radhakrishna.p: giving clarity on the solution

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.