I am having a problem parsing some complicated json from a webservice, and I cannot get the .replace method to work.
jsonArray = JSON.parse(d.responseText); /* var title = jsonArray.suggestions.homecare_options; title = title.replace(/{/g, ' '); */ var myString = jsonArray.suggestions.therapies.therapeutic_procedures; var option = Ti.UI.createLabel ({ text: myString.replace(/({:""})/g,"="), top: 10, color: 'black' }); view.add(option);I keep getting an error undefined is not a function
3 Answers
Accepted Answer
HI Andrew, can you put the log message here which says undefined is not a function... there might be some function or variable name.
and
also you can check the type o title and myString on which you are calling replace method... may be they are not string... use typeof() function to check the type
Hello andrew,
for replace char in perticular string, you can also use RegExp().
see this Link.
Hope it helps you...
I suspect that myString doesn't contain what you think it does. Have you tried debugging this code? You need to set a breakpoint and inspect your variables. You may already be familiar with the debugger, but if not, have a look at this video.
Your Answer
Think you can help? Login to answer this question!