Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replace is not defined, but why?

Tags:

javascript


can somebody tell me what is wrong?

JS Code

$.ajax({
    url:"http://www.google.com/complete/search?qu=chicken",
    success:function(data){

        var test_data = ''+data+''; // convert object to a string
        $('body').append(typeof(test_data));

        var test_data = replace.test_data(/[0-9]/,'X');
        $('body').append('<hr />'+test_data+' <hr />');

    },
    dataType:'jsonp',
    error:function(){
        alert('error');
    }
});

jsfiddle http://www.jsfiddle.net/V9Euk/664/

Thanks in advance!
Peter

like image 818
Peter Avatar asked Oct 10 '10 16:10

Peter


1 Answers

You got it backwards; it should be

test_data.replace(...);

Also, you don't need var before the second assignment to "test_data"; just the first one.

like image 56
Pointy Avatar answered Oct 03 '22 15:10

Pointy