Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

need help for recursive text replace function

recursive text replace

9:29 pm on Nov 18, 2011 (gmt 0)

I have to change the german character over on the php side before sending them back through ajax. That all works fine and I can make the change on the javascript side but it only gets the first occurance.
if (xmlhttp.readyState==4 && xmlhttp.status==200)
var txt=xmlhttp.responseText;
10:08 pm on Nov 18, 2011 (gmt 0)

WebmasterWorld Senior Member penders is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

Try passing a RegExp with the global modifier (g), rather than an ordinary string, as the first argument to the replace() method...

txt = txt.replace(/0000/g,"");

11:32 pm on Nov 18, 2011 (gmt 0)

Wow, thanks penders. That worked. I tried building several complex functions but was not getting anywhere.