I am facing problem in getting the variables from my response string. My response is like this:
responseText = {'page':'2','endOfPage':'yes','content':'abc'}
alert(responseText.page);
is returning undefined,
can anyone suggest how to do it??
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Your problem is that your responseText is in fact a string (
responseText = "{'page':'2','endOfPage':'yes','content':'abc'}";). You first have to parse it to create an object, this fails though because you are using single quotes, which are not valid JSON – you’ll need to use double quotes for resolving the problem:If you can’t change the JSON-generator implementation to return a response with double quotes, try to replace every single quote into a double quote like this: