admin管理员组文章数量:1414864
can somebody tell me what is wrong?
JS Code
$.ajax({
url:"",
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 /
Thanks in advance!
Peter
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
- get your hand on a good debugger like: getfirebug.com – gblazex Commented Oct 10, 2010 at 16:46
3 Answers
Reset to default 11You 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.
replace
is undefined. It is not an object.
Use replace
from the string prototype
"string".replace(//, "");
As you can see:
alert(String.prototype.replace)
Results in
function replace() {
[native code]
}
You should replace replace.test_data
by test_data.replace
本文标签: javascriptReplace is not definedbut whyStack Overflow
版权声明:本文标题:javascript - Replace is not defined, but why? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1739444698a2163409.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论