0

My ajax function:

function get_employee_list(Parameter){

    $.ajax({
        url: 'resource/php/search_profile.php',
        type: 'POST',
        data: { var1 : Parameter},
        async: false,
        success: function (response) {
            alert(response);
        },
        cache: false,
        contentType: false,
        processData: false
    });return false;
}  

My search_profile.php file:

<?php
    echo $_POST['var1'];
?>  

The response string says var1 is undefined variable. Is there anything wrong in my ajax syntax?

2 Answers 2

2
contentType: false,
processData: false

You've told jQuery not to convert the object to a suitably encoded format and not to set the content-type to tell PHP what that format is.

Consequently, PHP can't understand that data you are sending, so don't do that.

Sign up to request clarification or add additional context in comments.

Comments

0
$.post("resource/php/search_profile.php", {var1 : Parameter}, function(response){
    alert(response);
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.