애니메이션과 촬영 한 콘텐츠의 제한을 사용하여 mysqldb에서 콘텐츠를로드하려고합니다. 콘텐츠가 끝날 때 콘텐츠가 표시됩니다. 로딩 애니메이션이 계속로드됩니다.이 오류가 발생합니다.
내 스크립트 :
<script>
$(document).ready(function(){
var limit = 7;
var start = 0;
var action = 'inactive';
function load_country_data(limit, start)
{
$.ajax({
url:"/select_index",
method:"POST",
data:{limit:limit, start:start},
cache:false,
success:function(data)
{
var obj2 = JSON.parse(data);
console.log(data);
console.log(obj2);
var i=0;
var j=0;
for(i in obj2){
//for(j in obj2[i]){
$('#load_data').prepend("<form><div class='panel panel-white post panel-shadow user-post'><div class='post-heading'><div class='pull-left image'><img src='static/"+obj2[i][4]+"' class='img-circle avatar' alt='user profile image'></div><div class='pull-left meta'> <div class='title h5'><a href='#'><b>"+obj2[i][1]+"</b></a> made a post.</div><h6 class='text-muted time'>1 minute ago</h6></div></div> <div class='post-description'> <p>"+obj2[i][0]+"</p><div class='stats'><a href='#' class='btn btn-default stat-item'> <i class='fa fa-thumbs-up icon'></i>2</a> <a href='#' class='btn btn-default stat-item'><i class='fa fa-share icon'></i>12</a></div></div><div class='post-footer'><div class='input-group'> <input class='form-control' placeholder='Add a comment' type='text'></div> </div></div></form>" );
// }
}
// $('#load_data').append(data);
if(data == '')
{
$('#load_data_message').html("No Data Found");
action = 'active';
}
else
{
$('#load_data_message').html("<div class='loadingC'><div class='loadingCcerc'</div></div>");
action = "inactive";
}
}
});
}
if(action == 'inactive')
{
action = 'active';
load_country_data(limit, start);
}
$(window).scroll(function(){
if($(window).scrollTop() + $(window).height() > $("#load_data").height() && action == 'inactive')
{
action = 'active';
start = start + limit;
setTimeout(function(){
load_country_data(limit, start);
}, 800);
}
});
});
</script>
오류가 json.parse에서 발생한 것을 봅니다. My python script :
@app.route('/select_index',methods=["POST","GET"])
def select_index():
limit=request.args['limit']
print(limit)
start=request.args['start']
print(start)
select="SELECT comments.post,comments.name,comments.post_id , register.id,register.profile_pic,comments.id FROM comments,register WHERE register.id=comments.post_id ORDER BY comments.id DESC LIMIT "+str(start)+","+str(limit)+" "
con.execute(select)
fetch=con.fetchall()
print(fetch)
json_fetch=str(jsonify(fetch))
print(len(json_fetch))
if json_fetch=="<Response 3 bytes [200 OK]>":
return ""
else:
return jsonify(fetch)
파이썬 코드에서 빈 문자열을 반환합니다.
if json_fetch=="<Response 3 bytes [200 OK]>":
return ""
를 사용 JSON.parse("")
하면Uncaught SyntaxError: Unexpected end of JSON input
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다