Getting ajax response value

want to get value from my ajax response

and compare it

am just trying it like this

var getthis = $('#results').text(res.msg);

but not working

and a complete code is

  $(document).ready(function () {
    $("#Submit").click(function(event) {

    function Execute(){
        type: 'POST',
        url: 'somefile.php',
         success: function(res) {
    var getthis = $('#results').text(res.msg);
     if (getthis == "sayhello") {
     // do something
         // do something    


Could you give more information? What does “not working” mean?

am not getting var value for getthis

My bet is that you need to parse the variable ->

do this


to see what i looks like.

I haven’t coded in jQuery in a long time and someone else will probably give you a better answer. However, this should help you debug it on your own…maybe?

i dont think so, coz i have solved it without parsing