如果用户处于活动状态,则应显示:work / first div。
如果不活动(如果数据中没有任何内容),则应显示:not work / second div。
如何解决它?
*代码中的用户是免费的,没有敏感信息。
http://jsfiddle.net/rdcxozwn/3/
<button id="submit">Start</button>
<div class="work"></div>
<div class="notwork"></div>
var account = "**";
//if you type ** (not working account) its sould write 'not work' in the second div,
//but the else not working
$(document).ready(function(){
$("#submit").click(function(){
$.ajax({
url: "http://***/player_api.php?username=" + account + "&password=" + account + "&type=m3u",
success: function(response){
var data = response.user_info;
if (data.status.match("Active")){
$(".work").append("work\n");}
else{
$(".notwork").append("not work\n");}
}
});
});
});
答案 0 :(得分:0)
在进一步比较之前,您需要检查data.status && data.status.match("Active")
是否存在,请检查if (data.status && data.status.match("Active")){
$(".work").append("work\n");}
else{
$(".notwork").append("not work\n");}
之类的:
getApplicationContext()
以下是JSFIDDLE
的工作链接