Click here to Skip to main content
15,889,851 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am parsing some fields from HTTP response sent by Ajax request but I am unable to get the proper value.

Key value
----------------------
my_ID One
ID Two

when I am trying to fetch value of ID only my function return me value of my_ID.
I have used following code.
C#
myFunction(httpresponse,param)
{
    var val;
    if(httpresponse.match(param))
    {
      //Here it matches the ID with my_ID and return the value.
    }
}
    {


}

document.getElementById("ID").innerHTML=myFuntion(xmlhttp.responseText,"ID");

xmlhttp.responseText contains the data for both ID and my_ID field.


Pls suggest how to handle this.
Posted
Updated 5-Dec-13 23:41pm
v3
Comments
Sampath Lokuge 6-Dec-13 5:35am    
Can you put the parameters which you use also ?
SNI 6-Dec-13 5:38am    
document.getElementById("ID").innerHTML=myFuntion(xmlhttp.responseText,"ID");

xmlhttp.responseText contains the data for both ID and my_ID field.
Sampath Lokuge 6-Dec-13 5:46am    
Can you put sample of 'xmlhttp.responseText' values ?
RajeshvPatel 6-Dec-13 8:51am    
reply the json/xml string of xmlhttp.responseText

1 solution

I think you can get response is { "my_ID":"One","ID":"TWO" } and you need value of "ID"
For getting exact output update "myFunction" like below :

function myFunction(httpresponse,param){
return jsonresponse.param;
}

above details are valid for json single record.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900