YouTube ajax, .replace() 不起作用
YouTube ajax, .replace() not working
我正在使用下面的jquery,并且在var中添加.replace(","," ")video_tags=data.tags不会返回值。如何将逗号替换为空格。
http://jsfiddle.net/hJGe4/1/
$(document).ready(function () {
$(".search_input").focus();
$(".search_input").keyup(function () {
$("#video").html('');
var search_input = $(this).val();
var keyword = encodeURIComponent(search_input);
var yt_url = 'http://gdata.youtube.com/feeds/api/videos?q=' + keyword + '&format=5&max-results=6&v=2&alt=jsonc';
$.ajax({
type : "GET",
url : yt_url,
dataType : "jsonp",
success : function (response) {
if (response.data.items) {
$.each(response.data.items, function (i, data) {
var video_title = data.title;
var video_tags = data.tags.replace(",", " ");
var final = video_title + '<br/>' + video_tags + '<br/><br/><br/>';
$("#video").append(final);
});
} else {
$("#video").html("<div id='no'>No Video</div>");
}
}
});
});
});
var video_tags=data.tags.replace(",", " ");
应该是
var video_tags=data.tags.join(" ");
演示
相关文章:
- 替换变量时,JavaScript字符串replace()不起作用
- 使用replace方法替换innerHTML以及在Javascript中不起作用的正则表达式
- string.replace(“é”, “e”) 不起作用
- .replace 在 for 循环中不起作用吗?
- JavaScript Location.replace 不起作用
- YouTube ajax, .replace() 不起作用
- window.location.replace() 在窗体中不起作用
- JavaScript .replace() 部分的 url 不起作用
- 字符串正则表达式模式.replace(/{0}/, “$0.00”) 不起作用
- 使用window.location.replace重定向不起作用
- window.location.replace不起作用
- Javascript Regex replace在IE10中不起作用
- window.location.replace在客户端不起作用
- 如果重新加载了同一页,window.location.replace将不起作用
- Javascript replace()方法不起作用
- 试图更改onchange中的所有数字-onchange.replace没有'不起作用
- replace()函数在ie浏览器中不起作用
- Javascript中的Replace All不起作用
- 当我试图通过rails插入URL时,window.replace方法在js中不起作用
- Parameters .replace()两次jQuery插件不起作用