Click here to Skip to main content
15,949,741 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am receiving data in XMLHttpRequest object and while parsing it there are two strings that have common string. If I tried to get the string it is returning the value of first occurrence. PFB the code snippet.

document.getElementById("mystring").innerHTML=func(xmlhttp.responseText,"MYSTRING");
document.getElementById("mystringnew").innerHTML=func(xmlhttp.responseText,"MYSTRINGNEW");

C#
function func(mydata,myparam)
{
    var val;
    if(data.match(param))
    {
        var sindex=data.indexOf(param); -- At this place I am getting the index of MYSTRINGNEW instead of MYSTRING
        //alert(sindex);
     }
     return val;
}


XMLHttpResponse
---------------
'mystringnew' "Hello"
'mystring' "Hi"

so instead of receiving 'Hi' I am receiving 'Hello'

Please let me know is there any function in javascript to handle this.


Regds
Posted

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