How To: Execute code created by concantenating two strings

How To: Execute code created by concantenating two strings

Hi,

I'm trying to reuse the AJAX Success Function for another page. This function is in a .js file. The returned data is an array in one situation and a plain object in another. I have tried the below code  to differentiate the two. It does not work. Would appreciate help in trying to make this work.
R.



  1. if($.isArray(pData)) {
        x="pData[i]";   
    }
    else {
        x="pData";
    }

    alert(x+"['Display_Name']");  // doesn't work