jQuery 함수에 서버 측 값에 액세스하는 데 문제가 있습니다. 내 로컬 호스트 경로 (NewsRecord.php) AJAX URL로 (작동하고있다) 준 서버 경로가 작동하지 않는 경우 ... 나는 무엇이 문제인지는 모르겠다 - 서버 URL이 JSON 데이터를 출력한다. 정확히. 코드는 다음과 같습니다.내 jquery에 값을 가져 오는 중 오류가 발생했습니다.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script>
</head>
<body>
<div data-role="page" data-theme="a">
<div data-role="header">
<h1>News Letter</h1>
</div>
<div data-role="content" id="level" ></div>
<div data-role="footer"></div>
<h4>Powered by Handigital</h4>
</div>
<script type='text/javascript'>
$(document).ready(function() {
$.ajax({
url:'NewsRecord.php',
dataType:'json',
success:function(output) {
for(var u=0;u < output.length;u++)
{
$('#level').append('<div>Title :'+output[u].Title+'<br>Source :<a href='+output[u].links+'>'+output[u].Source+'</a><br>Category :'+output[u].Category+'</div><hr>');
}}
);
});
</script>
</body>
</html>
구문 오류로 시작 할 수 있습니다. 함수 안에 for 루프를 넣어야합니다. –
success-callback도 호출됩니까? 'console.dir (output)'의 결과는 무엇입니까? –
jQM에서'.ready()'를 사용하지 마십시오 http://jquerymobile.com/demos/1.2.1/docs/api/events.html – Omar