如果结果为空,我如何跳过下一行?目前,它(有时)“中断”并阻止脚本继续。
var title =(/(。*?)< / title> / m).exec(回复)[1];
$.get(url, function(response){
var title = (/<title>(.*?)<\/title>/m).exec(response)[1];
if (title == null || title == undefined){
return false;
}
var words = title.split(' ');
$.each(words, function(index, value){
$link.highlight(value + " ");
$link.highlight(" " + value);
});
});
答案 0 :(得分:3)
$.get(url, function(response){
var title = (/<title>(.*?)<\/title>/m).exec(response);
if (!title || !title[1]){
return false;
}
title=title[1];
var words = title.split(' ');
$.each(words, function(index, value){
$link.highlight(value + " ");
$link.highlight(" " + value);
});
});
你必须检查标题是否为空之前你在索引1得到结果