0

In the below code the $.POST method passes two variables to the php file empProfile.php which retrieves the employee profile from the database. Know I want to receive ID and Name from the php file to the jquery variables. Can someone help me.

data = {
        personnelNo: $('#personnelNo').val(),
        cnic: $('#cnic').val() 
        } //end of data

$.post( 
       "checkEmployee.php",
       data,
       function(data) {
                        var ID =; Name=;


                      } // end of function

      ); // end of post
    //} //end of if statement
}); // end of blur
2
  • 2
    To answer this, we need to know what your checkEmployee.php returns.. Please post that. Commented May 22, 2013 at 7:00
  • +1 Agree with @techfoobar. We need to know How you return your data from .php file? Commented May 22, 2013 at 7:05

1 Answer 1

1

Try this

var ID = '<?php echo $yourId;?>'; 

var Name='<?php echo $yourname;?>'; 
Sign up to request clarification or add additional context in comments.

5 Comments

QA has passed data from js to php but now he wants to back assign output from PHP to js from data variable which he will receive as a response.
@NullVoid read the question carefully. he wants to know how to send his php variables with jquery
@Robin, Question is saying that get How to get back data from php variable to jquery variable.... It means he's able to send data from jQuery to PHP but he wants back from PHP to jQuery. And in jQuery response, Will he receive PHP variables?
I want to receive ID and Name from the php file to the jQuery variables. That's the question he is asking. in other words he wants his PHP variables to jQuery
But it's not possible I think. May be he can send output with some string separator combinationation and then can split it in js and can use it.

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.